Bug 42287 - chunked encoded response to POST request to cgi script is abruptly closed
Summary: chunked encoded response to POST request to cgi script is abruptly closed
Status: NEEDINFO
Alias: None
Product: WebSH
Classification: Unclassified
Component: WebSH (show other bugs)
Version: unspecified
Hardware: All All
: P1 major (vote)
Target Milestone: ---
Assignee: websh-dev
URL: HTTPS
Keywords: APIBug
Depends on:
Blocks:
 
Reported: 2007-04-28 20:42 UTC by Basant Kumar Kukreja
Modified: 2018-01-05 19:58 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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
Trying 192.18.120.216...
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

x=abcd
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

2c
x=abcd
postdata =  ++
test2.php cgi script!

-------------------------------------------
$ curl -H "Connection: close" --data "x=abcd" --dump-header -
http://hostname:4014/cgi-bin/test2.pl
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
-------------------------------------------
#!/opt/php5.2.1/bin/php
<?
foreach ($_POST as $key => $value)
{
    print "$key=$value\n";
}
print "postdata = $HTTP_RAW_POST_DATA ++\n";
print "test2.php cgi script!\n";


?>
-------------------------------------------
#!/usr/bin/perl

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 192.18.120.216] (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
Host:agneyam
Accept: */*
Content-Type:application/x-www-form-urlencoded
Connection:close
Content-length:6

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