some update (if header key is non-unicode comformant)

This commit is contained in:
Miroslav Stampar 2011-02-25 09:43:04 +00:00
parent 2bbbc9a41e
commit 63b8156c00
2 changed files with 8 additions and 3 deletions

View File

@ -325,15 +325,19 @@ class HTTPConnection(httplib.HTTPConnection):
else: else:
raise CannotSendHeader() raise CannotSendHeader()
for key, item in self._headers.items():
del self._headers[key]
self._headers[unicodeToSafeHTMLValue(key)] = unicodeToSafeHTMLValue(item)
for header in ['Host', 'Accept-Encoding']: for header in ['Host', 'Accept-Encoding']:
if header in self._headers: if header in self._headers:
str = '%s: %s' % (header, self._headers[header]) str = '%s: %s' % (header, self._headers[header])
self._output(unicodeToSafeHTMLValue(str)) self._output(str)
del self._headers[header] del self._headers[header]
for header, value in self._headers.items(): for header, value in self._headers.items():
str = '%s: %s' % (header, value) str = '%s: %s' % (header, value)
self._output(unicodeToSafeHTMLValue(str)) self._output(str)
self._send_output() self._send_output()

View File

@ -158,7 +158,8 @@ class Connect:
headers[key] = item headers[key] = item
for key, item in headers.items(): for key, item in headers.items():
headers[key] = unicodeToSafeHTMLValue(item) del headers[key]
headers[unicodeToSafeHTMLValue(key)] = unicodeToSafeHTMLValue(item)
post = unicodeToSafeHTMLValue(post) post = unicodeToSafeHTMLValue(post)