From: Hans Dieter Pearcey Date: Sun, 26 Apr 2009 23:02:17 +0000 (+0000) Subject: do not mix syswrite/seek with buffered IO (as in CGI.pm); it causes difficult-to... X-Git-Tag: v1.0~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTTP-Request-AsCGI.git;a=commitdiff_plain;h=bd90442e9393c228b51c65627bacfd491f72b79d do not mix syswrite/seek with buffered IO (as in CGI.pm); it causes difficult-to-testably-reproduce bugs where the CGI environment doesn't see the entire STDIN content --- diff --git a/Changes b/Changes index 3b2e5e2..54a1bc4 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ This file documents the revision history for Perl extension HTTP::Request::AsCGI. +0.5_02 2009-04-29 + - Avoid mixing buffered and unbuffered IO and flush STDIN after writing + request content to it. (hdp) + 0.5 2006-01-20 - Fixed bug where content was overridden on 500 responses. diff --git a/lib/HTTP/Request/AsCGI.pm b/lib/HTTP/Request/AsCGI.pm index 0e7bc1f..f351e34 100644 --- a/lib/HTTP/Request/AsCGI.pm +++ b/lib/HTTP/Request/AsCGI.pm @@ -85,11 +85,14 @@ sub setup { if ( $self->request->content_length ) { - syswrite( $self->stdin, $self->request->content ) + $self->stdin->print($self->request->content) or croak("Can't write request content to stdin handle: $!"); - sysseek( $self->stdin, 0, SEEK_SET ) + $self->stdin->seek(0, SEEK_SET) or croak("Can't seek stdin handle: $!"); + + $self->stdin->flush + or croak("Can't flush stdin handle: $!"); } open( $self->{restore}->{stdin}, '<&', STDIN->fileno )