Skip to content

Fix for the fix of your (closed) issue #89 where self.headers[content-length] is set to 0 for all methods - #249

Merged
mikeal merged 1 commit into
request:masterfrom
sethbridges:master
Jun 4, 2012
Merged

mikeal merged 1 commit into
request:masterfrom
sethbridges:master

Conversation

@sethbridges

Copy link
Copy Markdown
Contributor

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).

mikeal added a commit that referenced this pull request Jun 4, 2012
Fix for the fix of your (closed) issue #89 where self.headers[content-length] is set to 0 for all methods
@mikeal
mikeal merged commit b827a43 into request:master Jun 4, 2012
sabaoongfx pushed a commit to sabaoongfx/request-modern that referenced this pull request Mar 10, 2026
Fix for the fix of your (closed) issue request#89 where self.headers[content-length] is set to 0 for all methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants