Subject: | Infinite-length reads with Content-Length: 0 |
CGI.pm 3.44 added a mode which reads until EOF is found, if
Content-Length isn't found. Unfortunately, the implementation means
that it does this if "Content-Length: 0" is specified. This breaks
HTTP::Server::Simple::CGI in HTTP/1.1 with keep-alive, for instance,
with LWP as a client -- the client hangs indefinitely. The attached
patch against 3.48 fixes the problem by adding a "not defined" check.
Subject: | content-length-0.patch |
diff -ru CGI.pm-3.48/lib/CGI.pm CGI.pm-3.48-patched/lib/CGI.pm
--- CGI.pm-3.48/lib/CGI.pm 2009-09-25 11:04:22.000000000 -0400
+++ CGI.pm-3.48-patched/lib/CGI.pm 2009-11-04 11:45:08.000000000 -0500
@@ -663,7 +663,7 @@
if ( $content_length > 0 ) {
$self->read_from_client(\$query_string,$content_length,0);
}
- else {
+ elsif (not defined $ENV{CONTENT_LENGTH}) {
$self->read_from_stdin(\$query_string);
# should this be PUTDATA in case of PUT ?
my($param) = $meth . 'DATA' ;
Only in CGI.pm-3.48-patched/lib: CGI.pm.orig