New submission from Arve Knudsen <arve.knud...@gmail.com>:

httplib doesn't specify the HTTP header 'content-length' for POST requests 
without data. Conceptually this makes sense, considering the empty content. 
However, IIS (7.5) servers don't accept such requests and respond with a 411 
status code. See this question on StackOverflow for reference: 
http://stackoverflow.com/questions/5915131/can-i-send-an-empty-http-post-webrequest-object-from-c-sharp-to-iis.

See also issue #223 of the Requests project, 
https://github.com/kennethreitz/requests/issues/223, which regards this problem 
in the context of the requests Python library.

The following code makes a data-less POST request to the HTTP sniffer Fiddler 
running on localhost:
import httplib
conn = httplib.HTTPConnection("localhost", 8888)
conn.request("POST", "/post", "", {})
conn.close()

Fiddler reports that it receives the following headers for the POST request, as 
you can see 'content-length' is not included:
POST http://localhost:8888/post HTTP/1.1
Host: localhost:8888
Accept-Encoding: identity

----------
components: Library (Lib)
messages: 159915
nosy: Arve.Knudsen
priority: normal
severity: normal
status: open
title: httplib doesn't specify content-length header for POST requests without 
data
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14721>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to