Skip to content

Instantly share code, notes, and snippets.

@nihen
Created October 6, 2009 16:12
Show Gist options
  • Save nihen/203167 to your computer and use it in GitHub Desktop.
Save nihen/203167 to your computer and use it in GitHub Desktop.
diff --git a/lib/Plack/Server/Apache2.pm b/lib/Plack/Server/Apache2.pm
index f2d80d0..d56b3c9 100644
--- a/lib/Plack/Server/Apache2.pm
+++ b/lib/Plack/Server/Apache2.pm
@@ -58,7 +58,19 @@ sub handler {
$r->status($res->[0]);
# TODO $r->sendfile support?
- Plack::Util::foreach($res->[2], sub { $r->puts(@_) });
+ my $puts_cb;
+ if ( $env->{'psgix.response_unbuffer'} ) {
+ $puts_cb = sub {
+ $r->puts(@_);
+ $r->rflush;
+ };
+ }
+ else {
+ $puts_cb = sub {
+ $r->puts(@_);
+ };
+ }
+ Plack::Util::foreach($res->[2], $puts_cb);
return Apache2::Const::OK;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment