Making a persistent HTTP connection

Benjamin Niemann pink at odahoda.de
Mon Nov 14 16:36:55 EST 2005


Diez B. Roggisch wrote:

> David Rasmussen wrote:
>> I use urllib2 to do some simple HTTP communication with a web server. In
>> one "session", I do maybe 10-15 requests. It seems that urllib2 opens op
>> a connection every time I do a request. Can I somehow make it use _one_
>> persistent connection where I can do multiple GET->"receive data" passes
>> before the connection is closed?
> 
> Are you sure HTTP supports that? This would be news to me - which
> doesn't mean much :)

It does (HTTP/1.1 at least) and it's called 'keep-alive'.

> And even if it works - what is the problem with connections being created?

Performance, network load...

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/



More information about the Python-list mailing list