From: Martin v. Löwis Date: Wed, 18 Aug 2004 12:46:26 +0000 (+0000) Subject: Patch #800236: add HTTPResponse.getheaders(). X-Git-Tag: v2.4a3~208 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=deacce2c8799c3aa5adfdc4263cc5bf1e933867e;p=python Patch #800236: add HTTPResponse.getheaders(). --- diff --git a/Doc/lib/libhttplib.tex b/Doc/lib/libhttplib.tex index 8badc71774..60fd7b1031 100644 --- a/Doc/lib/libhttplib.tex +++ b/Doc/lib/libhttplib.tex @@ -211,6 +211,10 @@ Get the contents of the header \var{name}, or \var{default} if there is no matching header. \end{methoddesc} +\begin{methoddesc}{getheaders}{} +Return a list of (header, value) tuples. \versionadded{2.4} +\end{methoddesc} + \begin{datadesc}{msg} A \class{mimetools.Message} instance containing the response headers. \end{datadesc} diff --git a/Lib/httplib.py b/Lib/httplib.py index c0d372ff7e..a4102eac5f 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -493,6 +493,12 @@ class HTTPResponse: raise ResponseNotReady() return self.msg.getheader(name, default) + def getheaders(self): + """Return list of (header, value) tuples.""" + if self.msg is None: + raise ResponseNotReady() + return self.msg.items() + class HTTPConnection: diff --git a/Misc/NEWS b/Misc/NEWS index 95d9f8db12..c6857dc9dd 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -44,6 +44,8 @@ Extension modules Library ------- +- HTTPResponse has now a getheaders method. + - Patch #1006219: let inspect.getsource handle '@' decorators. Thanks Simon Percivall.