httplib headers

David Brochu brochu121 at gmail.com
Fri Jul 31 02:57:56 CEST 2009


Using the following code I am trying to pass a header to my POST request.
(Note: urls masked)

file = sys.argv[0]
url = sys.argv[1]
conn = httplib.HTTPConnection("XX.XXX.XX.XXX",XXXX)
headers = {'content-type':'application/xml'}
conn.request("POST",url,file,headers)
response = conn.getresponse()
head = response.getheaders()
status = response.status
response = response.read()
print response, status, head

When I run this script and view the headers that get printed the following
displays:

[('content-length', '691'), ('proxy-connection', 'Keep-Alive'),
('connection', 'Keep-Alive'), ('pragma', 'no-cache'), ('cache-control',
'no-cache'), ('content-type', 'text/html; charset=utf-8')]
Why isn't my content-type header using the value I pass in from headers?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090730/99e547a7/attachment.html>


More information about the Python-list mailing list