David Brochu wrote:
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?

Aren't you just setting the headers for the "POST" you're sending
(you're posting a file whose content type is 'application/xml'), but
printing the headers of the response you receive (the content type of
the response is 'text/html; charset=utf-8')?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to