Merged revisions 83521 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83521 | senthil.kumaran | 2010-08-02 16:34:58 +0530 (Mon, 02 Aug 2010) | 3 lines

  Fix Issue8572  - httplib getheader() throws error instead of default
........
This commit is contained in:
Senthil Kumaran 2010-08-02 12:01:21 +00:00
parent fc499bcfd3
commit 3357840baf
3 changed files with 44 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."""