Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.4

Request #12900 Content-Length should be specified
Submitted: 2008-01-14 10:50 UTC
From: till Assigned: avb
Status: Closed Package: HTTP_Request (version 1.4.2)
PHP Version: 5.2.5 OS: n/a
Roadmaps: 1.4.3    
Subscription  


 [2008-01-14 10:50 UTC] till (Till Klampaeckel)
Description: ------------ I just ran into this last weekend, I think the Content-Length should *always* be specified even if no "body" is specified, in this case it should be 0 (obviously). I was doing a POST (empty body) against a nginx and it failed because no Content-Length was specified. I fixed this by doing HTTP_Request::addHeader('Content-Length', 0); but I think that HTTP_Request should do this by default. I think nginx follows the spec pretty closely, so this is why I guess HTTP_Request is off here. Instead of a null value for the body I also tried to supply an empty string as body but it wouldn't add Content-Length either. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13

Comments

 [2008-07-21 17:42 UTC] avb (Alexey Borzov)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.
 [2009-06-24 14:46 UTC] ldsandon (Luigi Sandon)
The request and the fix are both wrong. Content-length is an *entity* header, not a *request* header, thereby it makes very little sense to require it in a GET request - which has no entity. Some servers (i.e lighttp) may return 400 Bad request if it is present in a GET. Instead of asking PEAR to add a workaround for a server bug, the original poster should have asked nginx to fix their broken implementation.
 [2009-06-24 14:59 UTC] cweiske (Christian Weiske)
Settinc Content-Length to POST requests makes very much sense - in GET ones of course not.
 [2009-06-24 15:22 UTC] avb (Alexey Borzov)
Sorry, but that problem was already reported in bug #14740 which was already fixed in release 1.4.4 No sense adding comments here.