From f6350568d34334fc1ae432ca2ac8aa0f45ffd4f6 Mon Sep 17 00:00:00 2001 From: Vadim Belman Date: Mon, 21 Nov 2016 18:16:21 -0500 Subject: [PATCH] Item14221: Trying to get the postdata and $request->param() working again. CGI.pm does not support any other handles for normal operation but STDIN. FCGI::Request doesn't support any other mode but tie'ing of standard file handles. This combination make any other way of handling client input but via STDIN simply impossible. --- FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm | 12 ++++++++---- core/lib/Foswiki/Engine.pm | 3 +-- core/lib/Foswiki/Engine/CGI.pm | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm b/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm index 2808d3cdd9..c32c9e1853 100644 --- a/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm +++ b/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm @@ -65,13 +65,17 @@ sub run { or die "Failed to create FastCGI socket: $!"; } $args ||= {}; - + # Prepare output handles for FastCGI. - $this->{$_} = IO::Handle->new foreach qw(fhIN fhOUT fhERR); + $this->{$_} = IO::Handle->new foreach qw(fhOUT fhERR); + # This is a little trick to make all `print STDERR' clauses send their # output to the log file. May not work for spawned processes. - STDERR->fdopen($this->{fhERR}->fileno, "w"); - my $r = FCGI::Request( $this->{fhIN}, $this->{fhOUT}, $this->{fhERR}, \%ENV, $sock, + + STDERR->fdopen( $this->{fhERR}->fileno, "w" ); + + my $r = + FCGI::Request( \*STDIN, $this->{fhOUT}, $this->{fhERR}, \%ENV, $sock, &FCGI::FAIL_ACCEPT_ON_INTR ); my $manager; diff --git a/core/lib/Foswiki/Engine.pm b/core/lib/Foswiki/Engine.pm index 0e78650c3a..d149557df3 100644 --- a/core/lib/Foswiki/Engine.pm +++ b/core/lib/Foswiki/Engine.pm @@ -34,7 +34,7 @@ BEGIN { Constructs an engine object. -The default object has three initialized keys on it: =fhIN=, =fhOUT=, =fhERR=. +The default object has three initialized keys on it: =fhOUT=, =fhERR=. Those are filehandles used to communicate with HTTP server/environment and by default they're set to =STDIN=, =STDOUT=, and =STDERR= correspondingly. It is recommended to use =$engine->{fhERR}= instead of STDERR in order to get error @@ -58,7 +58,6 @@ sub new { # Standard file handles to support engines/environments where # communication is based on custom sockets. - fhIN => \*STDIN, fhOUT => \*STDOUT, fhERR => \*STDERR, }; diff --git a/core/lib/Foswiki/Engine/CGI.pm b/core/lib/Foswiki/Engine/CGI.pm index 2d87e25600..8a6020fada 100644 --- a/core/lib/Foswiki/Engine/CGI.pm +++ b/core/lib/Foswiki/Engine/CGI.pm @@ -234,7 +234,7 @@ sub prepareBody { # as breaking uploads (though cdot believes this is because of the # deprecated dual nature of param delivering lightweight file handles, # and it would probably work in Foswiki. Just not tried it) - my $cgi = new CGI( $this->{fhIN} ); + my $cgi = new CGI; my $err = $cgi->cgi_error; throw Foswiki::EngineException( $1, $2 ) if defined $err && $err =~ m/\s*(\d{3})\s*(.*)/;