AnyEvent-HTTPD

 view release on metacpan or  search on metacpan

samples/large_response_example  view on Meta::CPAN

            print "get next chunk, $last_pos of $size!\n";
         } else {
            print "sent last chunk, no more required!\n";
         }

         return unless $data_cb; # in case the connection went away...

         my $chunk = '';

         # use IO::AIO again, to async read from disk
         # you decide what chunks you want to send btw.
         # here we send 4096 bytes on each chunk read.
         aio_read $fh, $last_pos, 4096, $chunk, 0, sub {
            if ($_[0] > 0) {
               $last_pos += $_[0];
               print "read $_[0] bytes, sending them...\n";
               $data_cb->($chunk); # when we got another chunk, push it
                                   # over the http connection;
               $chunk = '';

               # and here we just return, and wait for the next call to



( run in 1.069 second using v1.01-cache-2.11-cpan-de7293f3b23 )