Skip to content

Commit ac87ed7

Browse files
committed
update example, since python.org is HTTPS-only now (closes #24118)
1 parent 8c59816 commit ac87ed7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Doc/library/http.client.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,18 +615,18 @@ Examples
615615
Here is an example session that uses the ``GET`` method::
616616

617617
>>> import http.client
618-
>>> conn = http.client.HTTPConnection("www.python.org")
619-
>>> conn.request("GET", "/index.html")
618+
>>> conn = http.client.HTTPSConnection("www.python.org")
619+
>>> conn.request("GET", "/")
620620
>>> r1 = conn.getresponse()
621621
>>> print(r1.status, r1.reason)
622622
200 OK
623623
>>> data1 = r1.read() # This will return entire content.
624624
>>> # The following example demonstrates reading data in chunks.
625-
>>> conn.request("GET", "/index.html")
625+
>>> conn.request("GET", "/")
626626
>>> r1 = conn.getresponse()
627627
>>> while not r1.closed:
628628
... print(r1.read(200)) # 200 bytes
629-
b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
629+
b'<!doctype html>\n<!--[if"...
630630
...
631631
>>> # Example of an invalid request
632632
>>> conn.request("GET", "/parrot.spam")
@@ -640,8 +640,8 @@ Here is an example session that uses the ``HEAD`` method. Note that the
640640
``HEAD`` method never returns any data. ::
641641

642642
>>> import http.client
643-
>>> conn = http.client.HTTPConnection("www.python.org")
644-
>>> conn.request("HEAD","/index.html")
643+
>>> conn = http.client.HTTPSConnection("www.python.org")
644+
>>> conn.request("HEAD", "/")
645645
>>> res = conn.getresponse()
646646
>>> print(res.status, res.reason)
647647
200 OK

0 commit comments

Comments
 (0)