Commit bdca9444 authored by Benjamin Peterson's avatar Benjamin Peterson

update example, since python.org is HTTPS-only now (closes #24118)

parent fd1fc83b
...@@ -615,18 +615,18 @@ Examples ...@@ -615,18 +615,18 @@ Examples
Here is an example session that uses the ``GET`` method:: Here is an example session that uses the ``GET`` method::
>>> import http.client >>> import http.client
>>> conn = http.client.HTTPConnection("www.python.org") >>> conn = http.client.HTTPSConnection("www.python.org")
>>> conn.request("GET", "/index.html") >>> conn.request("GET", "/")
>>> r1 = conn.getresponse() >>> r1 = conn.getresponse()
>>> print(r1.status, r1.reason) >>> print(r1.status, r1.reason)
200 OK 200 OK
>>> data1 = r1.read() # This will return entire content. >>> data1 = r1.read() # This will return entire content.
>>> # The following example demonstrates reading data in chunks. >>> # The following example demonstrates reading data in chunks.
>>> conn.request("GET", "/index.html") >>> conn.request("GET", "/")
>>> r1 = conn.getresponse() >>> r1 = conn.getresponse()
>>> while not r1.closed: >>> while not r1.closed:
... print(r1.read(200)) # 200 bytes ... print(r1.read(200)) # 200 bytes
b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"... b'<!doctype html>\n<!--[if"...
... ...
>>> # Example of an invalid request >>> # Example of an invalid request
>>> conn.request("GET", "/parrot.spam") >>> conn.request("GET", "/parrot.spam")
...@@ -640,8 +640,8 @@ Here is an example session that uses the ``HEAD`` method. Note that the ...@@ -640,8 +640,8 @@ Here is an example session that uses the ``HEAD`` method. Note that the
``HEAD`` method never returns any data. :: ``HEAD`` method never returns any data. ::
>>> import http.client >>> import http.client
>>> conn = http.client.HTTPConnection("www.python.org") >>> conn = http.client.HTTPSConnection("www.python.org")
>>> conn.request("HEAD","/index.html") >>> conn.request("HEAD", "/")
>>> res = conn.getresponse() >>> res = conn.getresponse()
>>> print(res.status, res.reason) >>> print(res.status, res.reason)
200 OK 200 OK
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment