Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI-Emulate-PSGI CPAN distribution.

Report information
The Basics
Id: 72684
Status: resolved
Priority: 0/
Queue: CGI-Emulate-PSGI

People
Owner: Nobody in particular
Requestors: JDB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: STDIN filehandle doesn't work when psgi.input isn't an IO object
Download (untitled) / with headers
text/plain 216b
For example under uWSGI all CGIs wrapped with CGI::Emulate::PSGI will not be able to retrieve the POST request data. (I was playing around with wrapping Bugzilla, and it works fine under Plackup, but not with uWSGI)
Subject: Re: [rt.cpan.org #72684] STDIN filehandle doesn't work when psgi.input isn't an IO object
Date: Wed, 23 Nov 2011 18:40:46 -0800
To: bug-CGI-Emulate-PSGI [...] rt.cpan.org
From: Tatsuhiko Miyagawa <miyagawa [...] gmail.com>
Download (untitled) / with headers
text/plain 896b
Sounds like a valid bug. I guess we have to wrap psgi.input with tied filehandle etc. for STDIN, instead of just providing psgi.input. On Wed, Nov 23, 2011 at 6:37 PM, Jan Dubois via RT <bug-CGI-Emulate-PSGI@rt.cpan.org> wrote: Show quoted text
> Wed Nov 23 21:37:13 2011: Request 72684 was acted upon. > Transaction: Ticket created by JDB >       Queue: CGI-Emulate-PSGI >     Subject: STDIN filehandle doesn't work when psgi.input isn't an IO object >   Broken in: (no value) >    Severity: (no value) >       Owner: Nobody >  Requestors: JDB@cpan.org >      Status: new >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=72684 > > > > For example under uWSGI all CGIs wrapped with CGI::Emulate::PSGI will > not be able to retrieve the POST request data. > > (I was playing around with wrapping Bugzilla, and it works fine under > Plackup, but not with uWSGI)
-- Tatsuhiko Miyagawa
Subject: [rt.cpan.org #72684] patch
Date: Thu, 8 Aug 2013 15:43:27 +0200
To: bug-CGI-Emulate-PSGI [...] rt.cpan.org
From: Bastian Blank <bastian [...] waldi.eu.org>
Download (untitled) / with headers
text/plain 988b
Patch for this problem. --- /usr/share/perl5/CGI/Emulate/PSGI.pm 2012-03-18 19:07:34.000000000 +0000 +++ CGI/Emulate/PSGI.pm 2013-08-08 13:37:20.834443137 +0000 @@ -10,6 +10,28 @@ our $VERSION = '0.14'; +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 + } + +package CGI::Emulate::PSGI; + sub handler { my ($class, $code, ) = @_; @@ -21,7 +43,8 @@ { 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'};
Subject: Re: [rt.cpan.org #72684] patch
Date: Thu, 8 Aug 2013 10:32:07 -0700
To: bug-CGI-Emulate-PSGI [...] rt.cpan.org
From: Tatsuhiko Miyagawa <miyagawa [...] gmail.com>
Download (untitled) / with headers
text/plain 1.3k
submit a pull-req on github https://github.com/tokuhirom/p5-cgi-emulate-psgi On Thu, Aug 8, 2013 at 6:43 AM, Bastian Blank via RT <bug-CGI-Emulate-PSGI@rt.cpan.org> wrote: Show quoted text
> Queue: CGI-Emulate-PSGI > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=72684 > > > Patch for this problem. > > --- /usr/share/perl5/CGI/Emulate/PSGI.pm 2012-03-18 19:07:34.000000000 +0000 > +++ CGI/Emulate/PSGI.pm 2013-08-08 13:37:20.834443137 +0000 > @@ -10,6 +10,28 @@ > > our $VERSION = '0.14'; > > +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 > + } > + > +package CGI::Emulate::PSGI; > + > sub handler { > my ($class, $code, ) = @_; > > @@ -21,7 +43,8 @@ > { > 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'}; > >
-- Tatsuhiko Miyagawa


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.