Fix for the fix of your (closed) issue #89 where self.headers[content-length] is set to 0 for all methods #249
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
turns out that setting content length to 0 for GETs to some servers causes them to respond with status 403.
For example, try out http://govwin.com.
The request:
GET / HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Language: en-US,en;q=0.8
Cache-Control: max-age=0
host: govwin.com
Accept-Encoding: gzip,deflate,sdch
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19
content-length: 0
The response:
HTTP/1.1 403 Forbidden
Date: Fri, 04 May 2012 22:53:43 GMT
Server: Apache/2.2.8 (CentOS)
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 2021
Connection: close
Content-Type: text/html; charset=UTF-8
Set-Cookie: BIGipServerdeltek_govwin.com_p=409138605.20480.0000; expires=Fri, 04-May-2012 23:08:43 GMT; path=/
This commit checks self.method before setting content-length:0 and only sets this value if the method is not a GET and not undefined (which resolves to GET).