do not mix syswrite/seek with buffered IO (as in CGI.pm); it causes difficult-to...
Hans Dieter Pearcey [Sun, 26 Apr 2009 23:02:17 +0000 (23:02 +0000)]
Changes
lib/HTTP/Request/AsCGI.pm

diff --git a/Changes b/Changes
index 3b2e5e2..54a1bc4 100644 (file)
--- 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.
 
index 0e7bc1f..f351e34 100644 (file)
@@ -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 )