leejo / cgi-fast

The new home for CGI::Fast, removing it from the original CGI.pm distribution
4 stars 5 forks source link

Doc: Do not suggest overriding the input file handle #16

Closed melak closed 7 years ago

melak commented 8 years ago

This break (at least) POST requests; it also isn't really relevant to the discussion as that's concerned about outputs rather than input.

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 6cb7d48612da173a3522b7c74c1f23889efe430b on melak:bugfix/fcgi_input_fh into ed6af0a6400a00e6c629b404c72dc3c0baf6c478 on leejo:master.

melak commented 8 years ago

So this is what's going on:

Using the method recommended in the docs (i.e. replacing the input file handle with a new IO::Handle), the script never receives the POST data:

$ truss -f -p 56696
56696: accept(3,{ AF_UNIX "" },0x7fffffffe0dc)   = 4 (0x4)
56696: select(5,{ 4 },0x0,0x0,{ 2.000000 })      = 1 (0x1)
56696: read(4,"\^A\^A\0\^A\0\b\0\0\0\^A\0\0\0\0"...,8192) = 1160 (0x488)

... then it just hangs here, with the web server timing out eventually,

Leaving input_fh alone (i.e. creating new handles for output_fh and error_fh only), it behaves as expected in every way I can think of:

$ truss -f -p 90376
90376: accept(3,{ AF_UNIX "" },0x7fffffffe0dc)   = 4 (0x4)
90376: select(5,{ 4 },0x0,0x0,{ 2.000000 })      = 1 (0x1)
90376: read(4,"\^A\^A\0\^A\0\b\0\0\0\^A\0\0\0\0"...,8192) = 1160 (0x488)
90376: write(4,"\^A\^F\0\^A\0\M-M\^C\0Content-Ty"...,240) = 240 (0xf0)
90376: shutdown(4,SHUT_WR)                       = 0 (0x0)
90376: select(5,{ 4 },0x0,0x0,{ 2.000000 })      = 1 (0x1)
90376: read(4,0x7fffffffddf0,1024)               = 0 (0x0)
90376: close(4)                                  = 0 (0x0)

... and the client gets the output.

Admittedly, I am not completely sure what's going on behind the curtain, this is based on observation mostly - however, befrore -> after is not working -> working.

leejo commented 8 years ago

Are you sure about this? I would expect to have seen this reported a long long time ago in the module if it were a problem given POST requests are going to be fundamental to a lot of peoples use of the module. Perhaps worth writing a test case and bisecting to see if it's a recent regression?

melak commented 7 years ago

No, I am not, but I currently have no better explanation as to why things are not working with overriding input_fh and do work without. May very well be a skew in my environment, still investigating.

melak commented 7 years ago

Colleagues (who made me look into this to begin with) have verified that POST suddenly started working once they stopped overriding input_fh. Their environment is guaranteed to be completely different from what I was experimenting with (save for the use of CGI::Fast).

I can't really add anything else to this - as you see fit.

leejo commented 7 years ago

OK, thanks for the investigation. Merged.

leejo commented 7 years ago

v2.12 on its way to CPAN. CI failures are due to issues with ExtUtils::Manifest and perl5.24