Skip to content

Commit

Permalink
Item14221: Trying to get the postdata and $request->param() working a…
Browse files Browse the repository at this point in the history
…gain.

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.
  • Loading branch information
vrurg committed Nov 21, 2016
1 parent 2792adc commit f635056
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
12 changes: 8 additions & 4 deletions FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions core/lib/Foswiki/Engine.pm
Expand Up @@ -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
Expand All @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Engine/CGI.pm
Expand Up @@ -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*(.*)/;
Expand Down

0 comments on commit f635056

Please sign in to comment.