HTTP Persistent connection

P

pedr0

Hi at all,

I have some problem with the httplib module, I would like have an HTTP persistent connection but when run this code :

#first request
http_connection = httplib.HTTPConnection(host)
http_connection.request(method,url,headers=headers)
response = http_connection.getresponse()
#second request

It works using two different socket, I can see that using wireshark, each request use two different source port.

I am using Python 2.6.1, some can suggest me how solve problem ?

Thanks in advance.

\pedr0
 
P

pedr0

I forget to insert second request.
host = "www.higuys.net"
#first request
http_connection = httplib.HTTPConnection(host)
http_connection.request(method,url_first,headers=headers)
response = http_connection.getresponse()
#second request
http_connection = httplib.HTTPConnection(host)
http_connection.request(method,url_second,headers=headers)
response = http_connection.getresponse()
 
J

John Gordon

In said:
I forget to insert second request.
host = "www.higuys.net"
#first request
http_connection = httplib.HTTPConnection(host)
http_connection.request(method,url_first,headers=headers)
response = http_connection.getresponse()
#second request
http_connection = httplib.HTTPConnection(host)
http_connection.request(method,url_second,headers=headers)
response = http_connection.getresponse()

I haven't used httplib much so maybe this is a dumb question, but if
you want to reuse the same connection, why are you declaring two separate
HTTPConnection objects? Wouldn't you want to reuse the same object?
 

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

Forum statistics

Threads
473,979
Messages
2,570,185
Members
46,727
Latest member
FelicaTole

Latest Threads

Top