httplib / connection

R

rhXX

hi all,

i'm using this tutorial example

import httplib

h = httplib.HTTP("www.python.org")
h.putrequest('GET','/index.html')
h.putheader('User-Agent','Lame Tutorial Code')
h.putheader('Accept','text/html')
h.endheaders()

errcode,errmsg, headers = h.getreply()
f = h.getfile() # Get file object for reading data
data = f.read()
f.close()

but always i get this tracing error, a timeout in h.endheaders()


File "ejemplo.py", line 331, in testA
h.endheaders()

File ".../lib/python2.4/httplib.py", line 795, in endheaders
self._send_output()

File ".../lib/python2.4/httplib.py", line 676, in _send_output
self.send(msg)

File ".../lib/python2.4/httplib.py", line 643, in send
self.connect()

File ".../lib/python2.4/httplib.py", line 627, in connect
raise socket.error, msg

socket.error: (110, 'Connection timed out')

must i do something about network before????

i would appreciate ur commenst
 
R

rhXX

hi all,

i'm using this tutorial example

import httplib

h = httplib.HTTP("www.python.org")
h.putrequest('GET','/index.html')
h.putheader('User-Agent','Lame Tutorial Code')
h.putheader('Accept','text/html')
h.endheaders()

errcode,errmsg, headers = h.getreply()
f = h.getfile() # Get file object for reading data
data = f.read()
f.close()

but always i get this tracing error, a timeout in h.endheaders()

File "ejemplo.py", line 331, in testA
h.endheaders()

File ".../lib/python2.4/httplib.py", line 795, in endheaders
self._send_output()

File ".../lib/python2.4/httplib.py", line 676, in _send_output
self.send(msg)

File ".../lib/python2.4/httplib.py", line 643, in send
self.connect()

File ".../lib/python2.4/httplib.py", line 627, in connect
raise socket.error, msg

socket.error: (110, 'Connection timed out')

must i do something about network before????

i would appreciate ur commenst


sorry, the timeout induced me to think about proxy connection
(evident ....). i found this example and worked fine!
import httplib, getpass, base64

print "Proxy Authentication Required:"
user = raw_input("Username: ")
passwd = getpass.getpass()
auth = base64.encodestring(user + ":" + passwd)

proxy_domain = "proxy.toto.com"
proxy_port = 8000

host = "www.tata.com"
url = "/"

h = httplib.HTTPConnection(proxy_domain, proxy_port)
h.putrequest('GET', "http://%s%s"%(host,url))
h.putheader('Host', host)
h.putheader('Proxy-Authorization', '''Basic %s''' % auth)
h.endheaders()
r = h.getresponse()
z = r.read()

print z

sorry by disturb ....
 
G

Gabriel Genellina

i'm using this tutorial example

Glad to see you could make it work finally. Which tutorial was that? The
httplib.HTTP class that you were using is very old and deprecated for
several years now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top