I've just started work on this as part of a larger stackless framework
I am building. I've created a base HTTP server that spawns off each
request handler in its own tasklet. I have a highler level WSGI
server that wraps the base class and implements the WSGI protocol.
The code is only a few days old. I can run the "Hello World" sample
WSGI app from PEP 333, but the error handling is very minimal.
The problem I am running into on error handling is that I am having a
very hard time closing the connection before the request has been
fully parsed. For example, I want to set limits on how many headers I
will accept or how big the body of a request can be. If the client
exceeds these limits, I want to disconnect them immediately. Ideally,
I'd like to be able to just call ebb_connection_schedule_close() in my
on_header_* and on_body callbacks and have libebb shutdown the parser
and call may on_close handler. Then I could clean up all of the
allocated requests, headers, and such in that handler.
Unfortunately, the best I have been able to do so far is to set an
error flag during parsing which all of my parsing callbacks use as a
signal to stop processing the request. This isn't the best solution
since libebb will still keep calling my handlers and reading the
request until the client closes the connection. Any suggestions on
how I could do this better?