File "in3sun34.py", line 33, in AttributeError: HTTPConnection
Chris Jackson
chris.jackson at ps.ge.com
Tue Jun 25 15:29:17 EDT 2002
Guillermo Fernandez <guillermo.fernandez at epfl.ch> wrote in message news:<mailman.1024982313.3269.python-list at python.org>...
> Hello!
>
> Please, if you answer me, include my e-mail in the answer as I am not
> abonned to this mailing list.
>
> I've written a little program to test python (I'm a beginner). Here it
> is:
>
> import httplib
>
> conn = httplib.HTTPConnection("www.python.org")
> print "CONNECTED"
> conn.request("GET", "/index.html
> response=conn.getresponse()
> answer=response.read()
> conn.close()
> print answer
>
> When I execute it, I obtain an error:
> [112]host-cfernand% python test.py
> Traceback (innermost last):
> File "test.py", line 3, in ?
> conn = httplib.HTTPConnection("www.python .org")
> AttributeError: HTTPConnection
>
> Line number 3 is:
> conn = httplib.HTTPConnection("www.python.org")
>
> I have searched in the internet and in the documentation and I have not
> been able to solve it.
>
> On the other hand, this program it works, so it's not a network problem:
> import urllib
> sock = urllib.urlopen("http://www.python.org/index.html")
> htmlSource = sock.read()
> sock.close()
> print htmlSource
>
> Thank you for your help!
>
> Guille
I have tried your first block of code and get the following error
message:
Traceback (most recent call last):
File "<string>", line 1, in ?
File "C:\Documents and Settings\jacksoc4\Desktop\http.py", line 5,
in ?
conn.request("GET", "/index.html")
File "C:\Python22\lib\httplib.py", line 537, in request
self._send_request(method, url, body, headers)
File "C:\Python22\lib\httplib.py", line 553, in _send_request
self.putrequest(method, url)
File "C:\Python22\lib\httplib.py", line 453, in putrequest
self.send(str)
File "C:\Python22\lib\httplib.py", line 395, in send
self.connect()
File "C:\Python22\lib\httplib.py", line 363, in connect
for res in socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM):
gaierror: (7, 'getaddrinfo failed')
The second code block using urllib works fine.
Perhaps the httplib.py file is buggy or the problem is something that
has to do the client/server protocol. socket.getaddrinfo is supposed
to return a list of (family, socktype, proto, canonname, sockaddr)
I'll continue looking to see what I can find.
More information about the Python-list
mailing list