forked from leejo/CGI.pm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rt-52469: adding a timeout for read_from_stdin
If we wait more than 5 seconds for something from stdin, the function timeouts and returns nothing
- Loading branch information
Showing
2 changed files
with
35 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More tests => 1; # last test to print | ||
|
||
use CGI; | ||
|
||
$ENV{REQUEST_METHOD} = 'PUT'; | ||
|
||
my $cgi = CGI->new; | ||
|
||
pass 'new() returned'; | ||
|
||
|
b132e1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look at this Yanick.
This is an area where I would rather follow a precedent than take our own approach. The CGI::Simple logic for reading from STDIN boils down to this:
my $length = $ENV{'CONTENT_LENGTH'} || 0;
I also tried to look at the Mojo approach. It's read loop looks like this:
Request body
Mojo defines "is_finished()" as being in any one of the following states: "done", "done_with_leftovers" and "error". I did not completely trace through the logic to see how the object gets put into all of these states.
However, I did mock-up a comparable test case for both CGI::Simple and Mojo, and neither of them hang by simply setting the REQUEST_METHOD to "PUT".
RFC 2616, the HTTP 1.1 RFC, includes this: " The presence of a message-body in a request is signaled by the
inclusion of a Content-Length or Transfer-Encoding header field in the request's message-headers."
Neither CGI.pm or CGI::Simple currently pay attention to the Transfer-Encoding header at all. Mojo appears to respect the header, but it's approach is different enough that it doesn't appear easy to "port" to CGI.pm.
So in summary, I have two questions: