diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2003-11-19 19:51:55 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2003-11-19 19:51:55 (GMT) |
commit | af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b (patch) | |
tree | f2bd9ca4e8a805c4a3578bab68f8f8340b52e64a | |
parent | a53f4eba19856613a55ccbcfdb8c862d24a691b9 (diff) | |
download | cpython-af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b.zip cpython-af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b.tar.gz cpython-af7dc8d8b86de39a16c6cf7bdba263ea1cedf26b.tar.bz2 |
Patch #831747: Add skip_accept_encoding parameter to putrequest.
-rw-r--r-- | Doc/lib/libhttplib.tex | 9 | ||||
-rw-r--r-- | Lib/httplib.py | 10 | ||||
-rw-r--r-- | Misc/NEWS | 2 |
3 files changed, 16 insertions, 5 deletions
diff --git a/Doc/lib/libhttplib.tex b/Doc/lib/libhttplib.tex index 50b4cf2..8badc71 100644 --- a/Doc/lib/libhttplib.tex +++ b/Doc/lib/libhttplib.tex @@ -174,11 +174,16 @@ Send data to the server. This should be used directly only after the \method{getreply()} has been called. \end{methoddesc} -\begin{methoddesc}{putrequest}{request, selector} +\begin{methoddesc}{putrequest}{request, selector\optional{, +skip\_host\optional{, skip_accept_encoding}}} This should be the first call after the connection to the server has been made. It sends a line to the server consisting of the \var{request} string, the \var{selector} string, and the HTTP version -(\code{HTTP/1.1}). +(\code{HTTP/1.1}). To disable automatic sending of \code{Host:} or +\code{Accept-Encoding:} headers (for example to accept additional +content encodings), specify \var{skip_host} or \var{skip_accept_encoding} +with non-False values. +\versionchanged[\var{skip_accept_encoding} argument added]{2.4} \end{methoddesc} \begin{methoddesc}{putheader}{header, argument\optional{, ...}} diff --git a/Lib/httplib.py b/Lib/httplib.py index a6ab647..0dfea33 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -596,18 +596,21 @@ class HTTPConnection: del self._buffer[:] self.send(msg) - def putrequest(self, method, url, skip_host=0): + def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0): """Send a request to the server. `method' specifies an HTTP request method, e.g. 'GET'. `url' specifies the object being requested, e.g. '/index.html'. + `skip_host' if True does not add automatically a 'Host:' header + `skip_accept_encoding' if True does not add automatically an + 'Accept-Encoding:' header """ # if a prior response has been completed, then forget about it. if self.__response and self.__response.isclosed(): self.__response = None - # + # in certain cases, we cannot issue another request on this connection. # this occurs when: # 1) we are in the process of sending a request. (_CS_REQ_STARTED) @@ -676,7 +679,8 @@ class HTTPConnection: # we only want a Content-Encoding of "identity" since we don't # support encodings such as x-gzip or x-deflate. - self.putheader('Accept-Encoding', 'identity') + if not skip_accept_encoding: + self.putheader('Accept-Encoding', 'identity') # we can accept "chunked" Transfer-Encodings, but no others # NOTE: no TE header implies *only* "chunked" @@ -116,6 +116,8 @@ Extension modules Library ------- +- httplib.HTTP.putrequest now offers to omit the implicit Accept-Encoding. + - Patch #841977: modulefinder didn't find extension modules in packages - imaplib.IMAP4.thread was added. |