Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 928fced

Browse files
committed
actualized example/reference, fix bug w/ nonnumeric port
1 parent c7ae920 commit 928fced

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

Lib/httplib.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# HTTP client class
22
#
3-
# See the following document for a tentative protocol description:
4-
# Hypertext Transfer Protocol (HTTP) Tim Berners-Lee, CERN
5-
# Internet Draft 5 Nov 1993
6-
# draft-ietf-iiir-http-00.txt Expires 5 May 1994
3+
# See the following URL for a description of the HTTP/1.0 protocol:
4+
# http://www.w3.org/hypertext/WWW/Protocols/
5+
# (I actually implemented it from a much earlier draft.)
76
#
87
# Example:
98
#
109
# >>> from httplib import HTTP
11-
# >>> h = HTTP('www.cwi.nl')
12-
# >>> h.putreqest('GET', '/index.html')
10+
# >>> h = HTTP('www.python.org')
11+
# >>> h.putrequest('GET', '/index.html')
1312
# >>> h.putheader('Accept', 'text/html')
1413
# >>> h.putheader('Accept', 'text/plain')
1514
# >>> h.endheaders()
@@ -18,7 +17,8 @@
1817
# ... f = h.getfile()
1918
# ... print f.read() # Print the raw HTML
2019
# ...
21-
# <TITLE>Home Page of CWI, Amsterdam</TITLE>
20+
# <HEAD>
21+
# <TITLE>Python Language Home Page</TITLE>
2222
# [...many more lines...]
2323
# >>>
2424
#
@@ -58,7 +58,8 @@ def connect(self, host, port = 0):
5858
if i >= 0:
5959
host, port = host[:i], host[i+1:]
6060
try: port = string.atoi(port)
61-
except string.atoi_error: pass
61+
except string.atoi_error:
62+
raise socket.error, "nonnumeric port"
6263
if not port: port = HTTP_PORT
6364
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
6465
if self.debuglevel > 0: print 'connect:', (host, port)

0 commit comments

Comments
 (0)