Subject: | Patch: Connection closes before last flush while streaming |
Since the pod isn't complete for how to properly stream, I'm not 100%
sure this patch is correct, but here goes anyways.
After you've completed streaming and you call DONE, it always yields
got_flush regardless if POE::Wheel::ReadWrite has something left in its
buffer to flush. Executing the got_flush event when it has data left in
its buffer leads to SimpleHTTP resetting/closing the connection
prematurely. This patch fixes it by allowing ReadWrite to flush the
last chunk itself.
Adrian
--- POE/Component/Server/SimpleHTTP.pm.orig 2011-05-03
17:53:56.000000000 -0700
+++ POE/Component/Server/SimpleHTTP.pm 2011-05-03 17:54:03.000000000 -0700
@@ -902,7 +902,9 @@
$self->_requests->{$id}->set_streaming(0);
$self->_requests->{$id}->set_done(1); # Finished streaming
# TODO: We might not get a flush, trigger it ourselves.
- $kernel->yield( 'got_flush', $id );
+ if ( !$self->_requests->{$id}->wheel->get_driver_out_messages ) {
+ $kernel->yield( 'got_flush', $id );
+ }
return;
}