Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
gh-102327: Extend docs for "url" and "headers" parameters to HTTPConnection.request()#102328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
86275f8
912df17
9013cd3
c0960c6
231bd9e
5a6293d
e6dc07c
dcf2480
f6f6e48
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -264,7 +264,9 @@ HTTPConnection Objects | ||
encode_chunked=False) | ||
This will send a request to the server using the HTTP request | ||
method *method* and the request URI *url*. The provided URL must be | ||
an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>` | ||
when using most HTTP methods (like ``GET`` or ``POST``). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This line makes me wonder if What do other people think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. A more specific phrasing would be: The provided *url* must be an absolute pathto conform with:rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`,unless connecting to an HTTP proxy server orusing the ``OPTIONS`` or ``CONNECT`` methods. And further down: A:rfc:`Host header <2616#section-14.23>` must be providedto conform with:rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`,unless connecting to an HTTP proxy server orusing the ``OPTIONS`` or ``CONNECT`` methods. A reader would still have to follow the link to determine the actual rules if they were talking to an HTTP proxy server (somewhat common?) or using Comments? Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That’s very clear! The I never use proxies but I think there are two cases:
I suppose the note here applies to the first kind only? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Feedback applied. I think this change is ready to merge! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Could you reply to the question about proxy? 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. RFC 2616 §1.3 defines a "proxy" as:
Therefore I speculate that the following requirement from§5.1.2 applies when a Python program attempts to connect toany kind of proxy:
I never use proxies myself so I have no empirical experience one way or the other. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. OK, let’s hope the people using proxies know how to handle them! | ||
If *body* is specified, the specified data is sent after the headers are | ||
finished. It may be a :class:`str`, a :term:`bytes-like object`, an | ||
@@ -279,7 +281,9 @@ HTTPConnection Objects | ||
iterable are sent as is until the iterable is exhausted. | ||
The *headers* argument should be a mapping of extra HTTP headers to send | ||
with the request. A :rfc:`Host header <2616#section-14.23>` | ||
must be provided to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>` | ||
when using most HTTP methods (like ``GET`` or ``POST``). | ||
If *headers* contains neither Content-Length nor Transfer-Encoding, | ||
but there is a request body, one of those | ||
@@ -293,26 +297,20 @@ HTTPConnection Objects | ||
Transfer-Encoding header will automatically be set instead of | ||
Content-Length. | ||
The *encode_chunked* argument is only relevant if Transfer-Encoding is | ||
specified in *headers*. If *encode_chunked* is ``False``, the | ||
HTTPConnection object assumes that all encoding is handled by the | ||
calling code. If it is ``True``, the body will be chunk-encoded. | ||
For example, to perform a ``GET`` request to ``https://docs.python.org/3/``:: | ||
>>> import http.client | ||
>>> host = "docs.python.org" | ||
>>> conn = http.client.HTTPSConnection(host) | ||
>>> conn.request("GET", "/3/", headers={"Host": host}) | ||
>>> response = conn.getresponse() | ||
>>> print(response.status, response.reason) | ||
200 OK | ||
.. note:: | ||
Chunked transfer encoding has been added to the HTTP protocol | ||