summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alex@spline.inf.fu-berlin.de>2014-12-05 16:50:19 +0100
committerroot <root@vm-support.spline.inf.fu-berlin.de>2014-12-05 16:50:19 +0100
commitf863c838292faeeafdd7e5bf781b717e9c3d6510 (patch)
treeda9eea438cf85894f257655c6eb3cd8038f59728
parent7040f7e9b14617774924458e557584a5c9ec6b2e (diff)
downloadcustom-f863c838292faeeafdd7e5bf781b717e9c3d6510.tar.gz
custom-f863c838292faeeafdd7e5bf781b717e9c3d6510.tar.bz2
custom-f863c838292faeeafdd7e5bf781b717e9c3d6510.zip
CGI::Emulate::PSGI: fix uwsgi support
https://github.com/tokuhirom/p5-cgi-emulate-psgi/pull/3
-rw-r--r--CGI/Emulate/PSGI.pm23
1 files changed, 22 insertions, 1 deletions
diff --git a/CGI/Emulate/PSGI.pm b/CGI/Emulate/PSGI.pm
index 335d6c0..27f42cb 100644
--- a/CGI/Emulate/PSGI.pm
+++ b/CGI/Emulate/PSGI.pm
@@ -21,7 +21,8 @@ sub handler {
{
local %ENV = (%ENV, $class->emulate_environment($env));
- local *STDIN = $env->{'psgi.input'};
+ local *STDIN;
+ tie (*STDIN, 'CGI::Emulate::PSGI::Handle', $env->{'psgi.input'});
local *STDOUT = $stdout;
local *STDERR = $env->{'psgi.errors'};
@@ -54,6 +55,26 @@ sub emulate_environment {
return wantarray ? %$environment : $environment;
}
+package CGI::Emulate::PSGI::Handle;
+
+require Tie::Handle;
+our @ISA = qw(Tie::Handle);
+
+sub READ {
+ my $self = shift;
+ my $bufref = \$_[0];
+ my (undef, $len, $offset) = @_;
+ my $buf;
+ my $ret = $$self->read($buf, $len, $offset);
+ $$bufref = $buf;
+ $ret;
+}
+
+sub TIEHANDLE {
+ my ($class, $ref) = @_;
+ bless \$ref, shift
+}
+
1;
__END__