@@ -264,7 +264,7 @@ HTTPConnection Objects
264
264
encode_chunked=False)
265
265
266
266
This will send a request to the server using the HTTP request
267
- method *method * and the selector *url *.
267
+ method *method * and the request URI *url *.
268
268
269
269
If *body * is specified, the specified data is sent after the headers are
270
270
finished. It may be a :class: `str `, a :term: `bytes-like object `, an
@@ -293,6 +293,22 @@ HTTPConnection Objects
293
293
Transfer-Encoding header will automatically be set instead of
294
294
Content-Length.
295
295
296
+ .. note ::
297
+ When using most HTTP methods (like ``GET `` or ``POST ``)
298
+ the provided ``url `` must be an absolute path and
299
+ a ``Host `` header must be provided to conform with
300
+ :rfc: `2616#section-5.1.2 `.
301
+
302
+ For example, to perform a ``GET `` request to ``https://xkcd.com/353/ ``::
303
+
304
+ >>> import http.client
305
+ >>> host = "xkcd.com"
306
+ >>> conn = http.client.HTTPSConnection(host)
307
+ >>> conn.request("GET", "/353/", headers={"Host": host})
308
+ >>> response = conn.getresponse()
309
+ >>> print(response.status, response.reason)
310
+ 200 OK
311
+
296
312
The *encode_chunked * argument is only relevant if Transfer-Encoding is
297
313
specified in *headers *. If *encode_chunked * is ``False ``, the
298
314
HTTPConnection object assumes that all encoding is handled by the
0 commit comments