Bug 49766 - POST request on CGI script generating empty body closes connection
Summary: POST request on CGI script generating empty body closes connection
Status: RESOLVED LATER
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_cgid (show other bugs)
Version: 2.2.14
Hardware: PC Linux
: P2 major (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: MassUpdate
: 49767 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-08-17 13:06 UTC by Reginald LIPS
Modified: 2018-11-07 21:09 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Reginald LIPS 2010-08-17 13:06:28 UTC
I just installed a fresh apache2 (2.2.14) on Ubuntu Lucid.
I wrote a small CGI script for test purpose:

~# cat /usr/lib/cgi-bin/test
#!/usr/bin/perl

print "Content-length: 0\r\n";
print "Content-type: text/plain\r\n\r\n";
~#

Here is my test:
~$ telnet 0 80
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
POST /cgi-bin/test HTTP/1.1
Host: localhost
Content-Length: 20

aaaaaaaaaaaaaaaaaa
Connection closed by foreign host.
~$

Connection is immediately closed without any response!
In the logs, I can see the following:

~# tail /var/log/apache2/access.log
127.0.0.1 - - [17/Aug/2010:19:03:10 +0200] "POST /cgi-bin/test HTTP/1.1" 200 0 "-" "-"
~# tail /var/log/apache2/error.log
[Tue Aug 17 19:03:10 2010] [error] [client 127.0.0.1] (104)Connection reset by peer: ap_content_length_filter: apr_bucket_read() failed

Clearly the connection is not 'reset by peer'

Please advise...
Comment 1 Ruediger Pluem 2010-08-18 02:11:23 UTC
I assume if you are just doing a get things work fine, correct?
Your CGI script is no capable of handling POST requests as it does not read the request body prior to sending an answer.
Comment 2 Reginald LIPS 2010-08-18 04:40:15 UTC
(In reply to comment #1)
> I assume if you are just doing a get things work fine, correct?
> Your CGI script is no capable of handling POST requests as it does not read the
> request body prior to sending an answer.

Thanks for the quick response.
Ok, but if I want to answer back to clients after reading few bytes of a 20MB POST request, it's no possible. Anyway, I can live with that, it works now.

However, the 200 response code in the logs is wrong.

Please merge this ticket with #49767, since it's the same problem.
Comment 3 Dan Poirier 2010-08-18 06:29:24 UTC
*** Bug 49767 has been marked as a duplicate of this bug. ***
Comment 4 William A. Rowe Jr. 2018-11-07 21:09:56 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd.

As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd.

If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question.

If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with.

Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.