[New-bugs-announce] [issue8572] httplib getheader() does not work as documented

Walter Woods report at bugs.python.org
Thu Apr 29 17:57:13 CEST 2010


New submission from Walter Woods <woodswalben at gmail.com>:

Calling HTTPResponse.getheader('Testabnew', 'Default') throws an exception rather than returning default, python 3.1.2.  Problem code appears to be line 601 of client.py:


    def getheader(self, name, default=None):
        if self.headers is None:
            raise ResponseNotReady()
-        return ', '.join(self.headers.get_all(name, default))

Which should probably changed to:

+        result = self.headers.get_all(name, None)
+        if result:
+            return ', '.join(result)
+        else:
+            return default

Not as elegant, but what appears to happen is if default is not an array, then get_all returns it, and the string join fails with a TypeError.

----------
messages: 104532
nosy: Walter.Woods
priority: normal
severity: normal
status: open
title: httplib getheader() does not work as documented
type: crash
versions: Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8572>
_______________________________________


More information about the New-bugs-announce mailing list