views:

674

answers:

2

I'm looking for a well-supported multithreaded Python HTTP server that supports chunked encoding replies. (I.e. "Transfer-Encoding: chunked" on responses). What's the best HTTP server base to start with for this purpose?

A: 

I am pretty sure that WSGI compliant servers should support that. Essentially, WSGI applications return iterable chunks, which the webserver returns. I don't have first hand experience with this, but here is a list of compliant servers.

I should think that it would be fairly easy to roll your own though, if WSGI servers dont meet what you are looking for, using the Python's builtin CGIHTTPServer. It is already multithreaded, so it would just be up to you to chunk the responses.

Shane C. Mason
+4  A: 

Twisted supports chunked transfer encoding (API link) (see also the API doc for HTTPChannel). There are a number of production-grade projects using Twisted (for example, Apple uses it for the iCalendar server in Mac OS X Server), so it's quite well supported and very robust.

Jarret Hardie
Thanks, I've heard of Twisted, but my first impression was that it was a bit heavyweight for my task. I'm going to take a second look, since it looks like you can download and run just twisted.web without the rest of the stuff.
slacy
I understand your feeling... twisted has a big API, seems a bit cultish and has somewhat of a learning curve. It put me off initially, too, but sometimes I do find it's the right tool for the job :-)
Jarret Hardie