mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Fix Issue8572 - httplib getheader() throws error instead of default
This commit is contained in:
parent
aed05eb6b8
commit
9f8dc4441f
3 changed files with 45 additions and 3 deletions
|
@ -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."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue