summaryrefslogtreecommitdiffstats
path: root/Doc/library/http.client.rst
diff options
context:
space:
mode:
authorMichael Handler <mh@grendel.net>2023-04-05 04:55:24 (GMT)
committerGitHub <noreply@github.com>2023-04-05 04:55:24 (GMT)
commit1a8f862e329c3872a11d4ef8eb85cf353ca2f4d5 (patch)
treead3f1ab9e0a427dd2fa61f976e169d06eea9a053 /Doc/library/http.client.rst
parenta62ff970750267441a7175b1bd6d6b2ec59d9a2c (diff)
downloadcpython-1a8f862e329c3872a11d4ef8eb85cf353ca2f4d5.zip
cpython-1a8f862e329c3872a11d4ef8eb85cf353ca2f4d5.tar.gz
cpython-1a8f862e329c3872a11d4ef8eb85cf353ca2f4d5.tar.bz2
gh-66897: Upgrade HTTP CONNECT to protocol HTTP/1.1 (#8305)
* bpo-22708: Upgrade HTTP CONNECT to protocol HTTP/1.1 (GH-NNNN) Use protocol HTTP/1.1 when sending HTTP CONNECT tunnelling requests; generate Host: headers if one is not already provided (required by HTTP/1.1), convert IDN domains to punycode in HTTP CONNECT requests. * Refactor tests to pass under -bb (fix ByteWarnings); missed some lines >80. * Use consistent 'tunnelling' spelling in Lib/http/client.py * Lib/test/test_httplib: Remove remnant of obsoleted test. * Use dict.copy() not copy.copy() * fix version changed * Update Lib/http/client.py Co-authored-by: bgehman <bgehman@users.noreply.github.com> * Switch to for/else: syntax, as suggested * Don't use for: else: * Sure, fine, w/e * Oops * 1nm to the left --------- Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: bgehman <bgehman@users.noreply.github.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Diffstat (limited to 'Doc/library/http.client.rst')
-rw-r--r--Doc/library/http.client.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst
index ad34161..38821b3 100644
--- a/Doc/library/http.client.rst
+++ b/Doc/library/http.client.rst
@@ -353,6 +353,13 @@ HTTPConnection Objects
The *headers* argument should be a mapping of extra HTTP headers to send with
the CONNECT request.
+ As HTTP/1.1 is used for HTTP CONNECT tunnelling request, `as per the RFC
+ <https://tools.ietf.org/html/rfc7231#section-4.3.6>`_, a HTTP ``Host:``
+ header must be provided, matching the authority-form of the request target
+ provided as the destination for the CONNECT request. If a HTTP ``Host:``
+ header is not provided via the headers argument, one is generated and
+ transmitted automatically.
+
For example, to tunnel through a HTTPS proxy server running locally on port
8080, we would pass the address of the proxy to the :class:`HTTPSConnection`
constructor, and the address of the host that we eventually want to reach to
@@ -365,6 +372,11 @@ HTTPConnection Objects
.. versionadded:: 3.2
+ .. versionchanged:: 3.12
+ HTTP CONNECT tunnelling requests use protocol HTTP/1.1, upgraded from
+ protocol HTTP/1.0. ``Host:`` HTTP headers are mandatory for HTTP/1.1, so
+ one will be automatically generated and transmitted if not provided in
+ the headers argument.
.. method:: HTTPConnection.connect()