Skip to content

Instantly share code, notes, and snippets.

@nihen
Created October 3, 2009 18:38
Show Gist options
  • Save nihen/200797 to your computer and use it in GitHub Desktop.
Save nihen/200797 to your computer and use it in GitHub Desktop.
From 638815a50913a983c67fe40efe83c00e86072be7 Mon Sep 17 00:00:00 2001
From: Masahiro Chiba <chiba@geminium.com>
Date: Sun, 4 Oct 2009 03:37:45 +0900
Subject: [PATCH] add sendfile impl
---
lib/Plack/Server/Apache2.pm | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/lib/Plack/Server/Apache2.pm b/lib/Plack/Server/Apache2.pm
index f2d80d0..2c6595b 100644
--- a/lib/Plack/Server/Apache2.pm
+++ b/lib/Plack/Server/Apache2.pm
@@ -58,7 +58,12 @@ sub handler {
$r->status($res->[0]);
# TODO $r->sendfile support?
- Plack::Util::foreach($res->[2], sub { $r->puts(@_) });
+ if ( Plack::Util::is_real_fh($res->[2]) ) {
+ $r->sendfile(sprintf('/proc/%s/fd/%s', $$, fileno $res->[2]));
+ }
+ else {
+ Plack::Util::foreach($res->[2], sub { $r->puts(@_) });
+ }
return Apache2::Const::OK;
}
--
1.5.6.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment