From: lkcl on
On Jul 13, 12:00 pm, Luke Kenneth Casson Leighton
<luke.leigh...(a)gmail.com> wrote:

> but... not being funny or anything, but basically i'm done already :)multitaskhttpdworks, it doesn't need stackless, i completed a JSONRPC
> service last night, i'll add POST of multi-part forms today, and i
> have everything that [GNUmed] will need.

ok instead of adding this to httpd.py i created an HTTP proxy out of
multitaskhttpd. i also cobbled together an example JSONRPC Server
which is highly likely to be used in gnumed, now. this modified
version of SimpleJSONRPCServer.py i had to rip bits of
BaseHTTPServer.py and add in Connection Keep-Alives on every
response. so, send_error needed modding/replacing, as did send_head,
list_directory and so on, all with a view to making sure that the HTTP
proxy is "happy".

the reason why the proxy works is because the incoming HTTP
connection results in an HTTP/1.1 proxy connection with Connection:
Keep-Alive set. so, even if the user's browser drops the connection,
the proxy permanently keeps open the connection to the upstream HTTP
server. in the case of the standard SimpleHTTPServer.py and so on
that results in the handle_request() loop basically serving that same
user _forever_. well... it would, if it wasn't for the fact that the
standard version of send_error() in BaseHTTPServer.py does
"Connection: Close", hence the reason why i had to replace it.

so, yeah - now you can do truly dreadful things like... create a
massive in-memory data structure and never have to serialise it
because the back-end process will _still_ be around pretty much
forever... and you can keep doing that until the server runs out of
memory. hurrah!

l.