1

As I read the sample code, I first need to open and connection

conn = httplib.HTTPSConnection(server)

and then I can send multiple requests without making a new connection:

 conn.request(...)

So does it mean that I have a persistent connection ? Or httplib will make a new connection every request ? How to ensure a persistent connection with httplib ?

w00d
  • 5,416
  • 12
  • 53
  • 85
  • possible duplicate of [Persistent HTTPS Connections in Python](http://stackoverflow.com/questions/7198552/persistent-https-connections-in-python) – Kimvais Aug 26 '12 at 18:24
  • related: [Persistence of urllib.request connections to a HTTP server](http://stackoverflow.com/questions/9772854/persistence-of-urllib-request-connections-to-a-http-server) – jfs Aug 26 '12 at 19:34

2 Answers2

0

No. Your best bet is httplib2.

Kimvais
  • 38,306
  • 16
  • 108
  • 142
0

Yes, the connection is persistent, assuming the server supports it. In the first example, you can verify that the connection sock attribute is reused. Note the response has to be closed, e.g. read(), each time as well.

A. Coady
  • 54,452
  • 8
  • 34
  • 40