471,342 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,342 software developers and data experts.

httplib / connection

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

Jun 12 '07 #1
3 3918
On Jun 12, 2:09 pm, rhXX <rh00...@gmail.comwrote:
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 ....
Jun 12 '07 #2
En Tue, 12 Jun 2007 09:09:12 -0300, rhXX <rh*****@gmail.comescribió:
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.

--
Gabriel Genellina

Jun 12 '07 #3
The
httplib.HTTP class that you were using is very old and deprecated for
several years now.

--
Gabriel Genellina
:-( oh ...., tks!

i took it from

www.ug.it.usyd.edu.au/~comp5315/lec-09.html

which class must i use?

tks in advance

Jun 13 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Roger Binns | last post: by
2 posts views Thread by scummer | last post: by
reply views Thread by Shagshag | last post: by
4 posts views Thread by Marcin Ciura | last post: by
4 posts views Thread by michaelparkin | last post: by
reply views Thread by Michael Ekstrand | last post: by
5 posts views Thread by runningwild | last post: by
reply views Thread by Dustin J. Mitchell | last post: by
6 posts views Thread by Haakon Riiser | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.