Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7)

Side by Side Diff: Doc/library/http.client.rst

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/html.entities.rst ('k') | Doc/library/http.cookies.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`http.client` --- HTTP protocol client 1 :mod:`http.client` --- HTTP protocol client
2 =========================================== 2 ===========================================
3 3
4 .. module:: http.client 4 .. module:: http.client
5 :synopsis: HTTP and HTTPS protocol client (requires sockets). 5 :synopsis: HTTP and HTTPS protocol client (requires sockets).
6 6
7 7
8 .. index:: 8 .. index::
9 pair: HTTP; protocol 9 pair: HTTP; protocol
10 single: HTTP; http.client (standard module) 10 single: HTTP; http.client (standard module)
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 200 OK 585 200 OK
586 >>> data = res.read() 586 >>> data = res.read()
587 >>> print(len(data)) 587 >>> print(len(data))
588 0 588 0
589 >>> data == b'' 589 >>> data == b''
590 True 590 True
591 591
592 Here is an example session that shows how to ``POST`` requests:: 592 Here is an example session that shows how to ``POST`` requests::
593 593
594 >>> import http.client, urllib.parse 594 >>> import http.client, urllib.parse
595 >>> params = urllib.parse.urlencode({'@number': 12524, '@type': 'issue', '@ac tion': 'show'}) 595 >>> params = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
596 >>> headers = {"Content-type": "application/x-www-form-urlencoded", 596 >>> headers = {"Content-type": "application/x-www-form-urlencoded",
597 ... "Accept": "text/plain"} 597 ... "Accept": "text/plain"}
598 >>> conn = http.client.HTTPConnection("bugs.python.org") 598 >>> conn = http.client.HTTPConnection("musi-cal.mojam.com:80")
599 >>> conn.request("POST", "", params, headers) 599 >>> conn.request("POST", "/cgi-bin/query", params, headers)
600 >>> response = conn.getresponse() 600 >>> response = conn.getresponse()
601 >>> print(response.status, response.reason) 601 >>> print(response.status, response.reason)
602 302 Found 602 200 OK
603 >>> data = response.read() 603 >>> data = response.read()
604 >>> data
605 b'Redirecting to <a href="http://bugs.python.org/issue12524">http://bugs.pyth on.org/issue12524</a>'
606 >>> conn.close() 604 >>> conn.close()
607 605
608 606
609 .. _httpmessage-objects: 607 .. _httpmessage-objects:
610 608
611 HTTPMessage Objects 609 HTTPMessage Objects
612 ------------------- 610 -------------------
613 611
614 An :class:`http.client.HTTPMessage` instance holds the headers from an HTTP 612 An :class:`http.client.HTTPMessage` instance holds the headers from an HTTP
615 response. It is implemented using the :class:`email.message.Message` class. 613 response. It is implemented using the :class:`email.message.Message` class.
616 614
617 .. XXX Define the methods that clients can depend upon between versions. 615 .. XXX Define the methods that clients can depend upon between versions.
OLDNEW
« no previous file with comments | « Doc/library/html.entities.rst ('k') | Doc/library/http.cookies.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+