|
1 | 1 | # HTTP client class |
2 | 2 | # |
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.) |
7 | 6 | # |
8 | 7 | # Example: |
9 | 8 | # |
10 | 9 | # >>> 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') |
13 | 12 | # >>> h.putheader('Accept', 'text/html') |
14 | 13 | # >>> h.putheader('Accept', 'text/plain') |
15 | 14 | # >>> h.endheaders() |
|
18 | 17 | # ... f = h.getfile() |
19 | 18 | # ... print f.read() # Print the raw HTML |
20 | 19 | # ... |
21 | | -# <TITLE>Home Page of CWI, Amsterdam</TITLE> |
| 20 | +# <HEAD> |
| 21 | +# <TITLE>Python Language Home Page</TITLE> |
22 | 22 | # [...many more lines...] |
23 | 23 | # >>> |
24 | 24 | # |
@@ -58,7 +58,8 @@ def connect(self, host, port = 0): |
58 | 58 | if i >= 0: |
59 | 59 | host, port = host[:i], host[i+1:] |
60 | 60 | try: port = string.atoi(port) |
61 | | - except string.atoi_error: pass |
| 61 | + except string.atoi_error: |
| 62 | + raise socket.error, "nonnumeric port" |
62 | 63 | if not port: port = HTTP_PORT |
63 | 64 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
64 | 65 | if self.debuglevel > 0: print 'connect:', (host, port) |
|
0 commit comments