How do I post non-ASCII characters using httplib when content-type is “application/xml”
问题 I've implemented a Pivotal Tracker API module in Python 2.7. The Pivotal Tracker API expects POST data to be an XML document and "application/xml" to be the content type. My code uses urlib/httplib to post the document as shown: request = urllib2.Request(self.url, xml_request.toxml('utf-8') if xml_request else None, self.headers) obj = parse_xml(self.opener.open(request)) This yields an exception when the XML text contains non-ASCII characters: File "/usr/lib/python2.7/httplib.py", line 951,