httplib design question

Aahz Maruch aahz at panix.com
Sun Jun 3 15:38:08 CEST 2001


In article <Xns90B4A13C8CCBEgustaflalgonetse at 194.213.69.148>,
Gustaf Liljegren <gustafl at algonet.se> wrote:
>
>I have noticed that the HTTP method doesn't try to connect to the server:
>
>>>> h = httplib.HTTP('abc')
>>>>
>
>So I can give it a bad URL, and things will be fine until I try to get 
>something with the putrequest() method.
>
>>>> h.putrequest('GET', '/index.html')
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "e:\python20\lib\httplib.py", line 425, in putrequest
>    self.send(str)
>  File "e:\python20\lib\httplib.py", line 367, in send
>    self.connect()
>  File "e:\python20\lib\httplib.py", line 351, in connect
>    self.sock.connect((self.host, self.port))
>  File "<string>", line 1, in connect
>socket.error: host not found
>>>>
>
>Why doesn't the HTTP method handle this check instead? Here's what I'm 
>trying to do:

I'm not the person who wrote it, so I can't give you a definitive
answer.  However, httplib is intended to be a low-level interface, so
it's not surprising that you have to do all this work.  Consider using
urllib instead.
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het Pythonista   http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

I surf faster than you do, monkey boy.  (My take on Netscape vs. Lynx)



More information about the Python-list mailing list