Bug 42287

Summary: chunked encoded response to POST request to cgi script is abruptly closed
Product: Apache httpd-test Reporter: Basant Kumar Kukreja <basant.kukreja>
Component: frameworkAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEW ---    
Severity: normal CC: garyknight1991newest
Priority: P5 Keywords: APIBug
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: OpenVMS   

Description Basant Kumar Kukreja 2007-04-28 20:42:31 UTC
When I send a POST request to a php/perl script. Chunked Response from apache
2.2.x/trunk is abruptly closed. Sometimes it works fine and sometimes we don't
see last 0 in chunked response.

telnet hostname 4004
Connected to localhost
Escape character is '^]'.
POST /cgi-bin/test2.php HTTP/1.1
Host: localhost:4004
Accept: */*
Content-Type: application/x-www-form-urlencoded
Connection: close
Content-Length: 6

HTTP/1.1 200 OK
Date: Sat, 28 Apr 2007 03:12:05 GMT
Server: Apache/2.3.0-dev (Unix) mod_ssl/2.3.0-dev OpenSSL/0.9.8a DAV/2
X-Powered-By: PHP/5.2.1
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

postdata =  ++
test2.php cgi script!

$ curl -H "Connection: close" --data "x=abcd" --dump-header -
HTTP/1.1 200 OK
Date: Sun, 29 Apr 2007 03:24:03 GMT
Server: Apache/2.2.5-dev (Unix) mod_ssl/2.2.5-dev OpenSSL/0.9.8a DAV/2
Content-type : text/html
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain

test2.pl cgi script!
curl: (18) transfer closed with outstanding read data remaining
foreach ($_POST as $key => $value)
    print "$key=$value\n";
print "postdata = $HTTP_RAW_POST_DATA ++\n";
print "test2.php cgi script!\n";


print "Content-type : text/html\r\n";
print "\r\n";

print "test2.pl cgi script!\n";

In error log sometimes I saw this message.
[Sat Apr 28 20:27:25 2007] [error] [client] (104)Connection reset
by peer: ap_content_length_filter: apr_bucket_read() failed

This happens with both httpd-2.2.x and trunk.
I am using apr and apr-util from trunk.
This could potentially be apr bug too.

The behavior is not at all predictable. It sometimes works ok and sometimes fails.
Comment 1 rahul 2008-08-14 04:45:33 UTC
Not able to reproduce in trunk, 
This is what I used with test2.pl, I do not get an error here or in the error logs

for x in $(seq -w 00 99);
do (echo "POST /cgi-bin/test2.pl HTTP/1.1
Accept: */*

x=abcd" | nc agneyam 8080 > resp/r.$x || echo err &);