Fix Issue8572 - httplib getheader() throws error instead of default

This commit is contained in:
Senthil Kumaran 2010-08-02 11:04:58 +00:00
parent aed05eb6b8
commit 9f8dc4441f
3 changed files with 45 additions and 3 deletions

View file

@ -602,7 +602,11 @@ class HTTPResponse(io.RawIOBase):
def getheader(self, name, default=None):
if self.headers is None:
raise ResponseNotReady()
return ', '.join(self.headers.get_all(name, default))
headers = self.headers.get_all(name) or default
if isinstance(headers, str) or not hasattr(headers, '__iter__'):
return headers
else:
return ', '.join(headers)
def getheaders(self):
"""Return list of (header, value) tuples."""