httplib headers

David Brochu brochu121 at
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'}
response = conn.getresponse()
head = response.getheaders()
status = response.status
response =
print response, status, head

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

[('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: <>

More information about the Python-list mailing list