mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
merge 3.4 (#24118)
This commit is contained in:
commit
b174b85c1a
1 changed files with 6 additions and 6 deletions
|
@ -427,18 +427,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.HTTPSConnection("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")
|
||||
|
@ -452,8 +452,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.HTTPSConnection("www.python.org")
|
||||
>>> conn.request("HEAD", "/")
|
||||
>>> res = conn.getresponse()
|
||||
>>> print(res.status, res.reason)
|
||||
200 OK
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue