in reply to AnyEvent::HTTPD -> async response generation

Take a look at the test suite, in t/06_long_resp.t there is the approach on how to generate a response using multiple callbacks:

$h->reg_cb ( '/test' => sub { my ($httpd, $req) = @_; $req->respond ({ content => ['text/plain', sub { my ($data_cb) = @_; return unless $data_cb; $data_cb->(substr $SENT, 0, 10, ''); }] }); }, );

Basically, it is the same approach that Plack uses. Your ->respond call passes in a subroutine, that gets another callback as a parameter. You then call this callback every time you have more content for the response.