Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ac87ed7e
Commit
ac87ed7e
authored
May 03, 2015
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update example, since python.org is HTTPS-only now (closes #24118)
parent
8c59816b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
Doc/library/http.client.rst
Doc/library/http.client.rst
+6
-6
No files found.
Doc/library/http.client.rst
View file @
ac87ed7e
...
...
@@ -615,18 +615,18 @@ Examples
Here is an example session that uses the ``GET`` method::
>>> import http.client
>>> conn = http.client.HTTPConnection("www.python.org")
>>> conn.request("GET", "/
index.html
")
>>> conn = http.client.HTTP
S
Connection("www.python.org")
>>> conn.request("GET", "/")
>>> r1 = conn.getresponse()
>>> print(r1.status, r1.reason)
200 OK
>>> data1 = r1.read() # This will return entire content.
>>> # The following example demonstrates reading data in chunks.
>>> conn.request("GET", "/
index.html
")
>>> conn.request("GET", "/")
>>> r1 = conn.getresponse()
>>> while not r1.closed:
... 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
>>> conn.request("GET", "/parrot.spam")
...
...
@@ -640,8 +640,8 @@ Here is an example session that uses the ``HEAD`` method. Note that the
``HEAD`` method never returns any data. ::
>>> import http.client
>>> conn = http.client.HTTPConnection("www.python.org")
>>> conn.request("HEAD",
"/index.html
")
>>> conn = http.client.HTTP
S
Connection("www.python.org")
>>> conn.request("HEAD",
"/
")
>>> res = conn.getresponse()
>>> print(res.status, res.reason)
200 OK
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment