473,249 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,249 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 4050
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Roger Binns | last post by:
I have just spent several weeks mashing xmlrpc, httplib and SSL (from M2Crypto) to work together. The current standard library has several problems: - Builtin SSL is pretty much useless if you...
2
by: scummer | last post by:
Hi, I am having a problem with the httplib HTTPConnection object. While I can easily send requests that don't have any payload (ie. "get"), I encounter issues if I want to post xml data. If you...
0
by: Shagshag | last post by:
hello, how can i set multiple cookies like : Set-Cookie: cookiename1=value1; expires=Tue, 31-Mar-09 11:17:43 GMT; path=/; domain=www.domain.com Set-Cookie: cookiename2=value2; expires=Tue,...
4
by: Marcin Ciura | last post by:
I have the following problem with HTTPResponse: import httplib #, select .... connection = httplib.HTTPConnection(host) connection.connect() connection.request('GET', url) response =...
4
by: michaelparkin | last post by:
Hi, Sorry to post what might seem like a trivial problem here, but its driving me mad! I have a simple https client that uses httplib to post data to a web server. When I post over http &...
0
by: Michael Ekstrand | last post by:
In the course of my current project, I've had to deal with connecting to an HTTP server that isn't fully compliant with the HTTP requirements for chunked encodings. Rather than sending the...
5
by: runningwild | last post by:
Helo, This is the first time I have cared about httplib's HTTPSConnection. In the docs I read "Note: HTTPS support is only available if the socket module was compiled with SSL support." ...
0
by: Dustin J. Mitchell | last post by:
I'm building an interface to Amazon's S3, using httplib. It uses a single object for multiple transactions. What's happening is this: HTTP PUT /unitest-temp-1161039691 HTTP/1.1 HTTP Date: Mon,...
6
by: Haakon Riiser | last post by:
After a long debugging session while scripting my webmail, I believe I have traced the problem to the way httplib sends POST requests. I have compared tcpdump listings from Python 2.4.3 and...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.