From: Christian Hansen Date: Mon, 17 Oct 2005 00:23:20 +0000 (+0000) Subject: Default setup dont redirect STDERR X-Git-Tag: v1.0~48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTTP-Request-AsCGI.git;a=commitdiff_plain;h=17b370b08f2f8a06dca23575c024d7dc8ee13532 Default setup dont redirect STDERR --- diff --git a/examples/daemon.pl b/examples/daemon.pl index 9a040e3..11a51d6 100644 --- a/examples/daemon.pl +++ b/examples/daemon.pl @@ -41,7 +41,7 @@ while ( my $client = $server->accept ) { $c->restore; my $response = $c->response; - + # to prevent blocking problems in single threaded daemon. $response->header( Connection => 'close' ); diff --git a/lib/HTTP/Request/AsCGI.pm b/lib/HTTP/Request/AsCGI.pm index 42822c7..be0bece 100644 --- a/lib/HTTP/Request/AsCGI.pm +++ b/lib/HTTP/Request/AsCGI.pm @@ -21,8 +21,7 @@ sub new { restored => 0, setuped => 0, stdin => IO::File->new_tmpfile, - stdout => IO::File->new_tmpfile, - stderr => IO::File->new_tmpfile + stdout => IO::File->new_tmpfile }; $self->{enviroment} = { @@ -68,8 +67,8 @@ sub setup { open( STDIN, '<&=', $self->stdin->fileno ) or croak("Can't open stdin: $!"); - binmode( $self->stdin, ':raw' ); - binmode( STDIN, ':raw' ); + binmode( $self->stdin ); + binmode( STDIN ); if ( $self->request->content_length ) { @@ -87,8 +86,8 @@ sub setup { open( STDOUT, '>&=', $self->stdout->fileno ) or croak("Can't open stdout: $!"); - binmode( $self->stdout, ':raw' ); - binmode( STDOUT, ':raw' ); + binmode( $self->stdout ); + binmode( STDOUT); } if ( $self->stderr ) { @@ -98,8 +97,8 @@ sub setup { open( STDERR, '>&=', $self->stderr->fileno ) or croak("Can't open stderr: $!"); - binmode( $self->stderr, ':raw' ); - binmode( STDERR, ':raw' ); + binmode( $self->stderr ); + binmode( STDERR ); } { @@ -268,6 +267,10 @@ HTTP::Request::AsCGI - Setup a CGI enviroment from a HTTP::Request =head1 BUGS +=item THANKS TO + +Thomas L. Shinnick for his valuable win32 testing. + =head1 AUTHOR Christian Hansen, C diff --git a/t/04io.t b/t/04io.t index e5c4539..029c5a7 100644 --- a/t/04io.t +++ b/t/04io.t @@ -5,6 +5,7 @@ use Test::More tests => 3; use strict; use warnings; +use IO::File; use HTTP::Request; use HTTP::Request::AsCGI; @@ -13,7 +14,9 @@ $r->content('STDIN'); $r->content_length(5); $r->content_type('text/plain'); -my $c = HTTP::Request::AsCGI->new($r)->setup; +my $c = HTTP::Request::AsCGI->new($r); +$c->stderr(IO::File->new_tmpfile); +$c->setup; print STDOUT 'STDOUT'; print STDERR 'STDERR'; diff --git a/t/05env.t b/t/05env.t index c5c5351..c21c5cb 100644 --- a/t/05env.t +++ b/t/05env.t @@ -12,7 +12,6 @@ use HTTP::Request::AsCGI; my $r = HTTP::Request->new( GET => 'http://www.host.com/my/path/?a=1&b=2' ); my $c = HTTP::Request::AsCGI->new($r); $c->stdout(undef); -$c->stderr(undef); $c->setup;