xmlrpc, httplib and SSL (HTTP 1.1 XMLRPC client)

Etienne Posthumus ep at epoz.org
Fri Apr 9 05:29:48 EDT 2004


On Apr 1, 2004, at 7:13 PM, Roger Binns wrote:
> Are you sure you are actually getting persistent connections?  The
> code will auto-close and auto-open the connection even just keeping
> the same HTTP connection object.

Yes, I definitely get persistent connections. I sat staring at the 
server logs, the requests kept coming from the same source-port.
Which code do you refer to that auto-closes, and auto-opens the 
connection?
If you use that Persistent transport it skips the .close() after each 
request part.

> In order for the connection to not be auto-closed, the remote end
> must return a HTTP/1.1 response (see 
> httplib.HTTPResponse._check_close).

Also remember to include a Content-Length header.
That one bit me before, in some of my replies I had forgotten to 
include it in my server. You can then very clearly see the clients 
dropping the connection, and rightly so.

> If your server end is Python, then it will always close the connection
> unless the request was HTTP/1.1 *and* a 'Connection: keep-alive' header
> was sent, which the Python client does not do.

Which Python client do you refer to? I presume you mean the standard 
xmlrpclib client, and then yes, it explicitly does HTTP 1.0.

BTW, in HTTP 1.1 keeping connections open is the default, so you do NOT 
have to specify Connection: keep-alive in the header.
Although it is the default to keep the connections open, the client or 
the server can close them at any time.


---
Etienne Posthumus
Amsterdam, Nederland
Python, Zope, Quixote -
programmer for hire... but not for sale.





More information about the Python-list mailing list