Hi,
Newbie opinion here.
Since we are talking about Tulip and PEP 3156, I think it's high time we address some of the design flaws in WSGI 1.0
One major problem with WSGI is that it can not handle true post-response hooks.
The closest hack I found is this:
As discussed by Graham Dumpleton here
Although the response was returned to the client, It will still hold the http connection open until __callback finishes.
While it's pretty common design pattern for a post-response hook in modern Web world. I can think a few usage:
- User uploads file, return HTML says Upload OK, then Web worker continue to transfer file to Amazon S3, which is slow and takes some time.
- After a series of user interaction on a web page, using the existing db connection to write OLAP logs of later analysis.
- notify the http request to another ZMQ/XMPP connection
Currently, Celery is extremely popular (at least in Django or other non-async web frameworks). But IMHO it's too heavy weight and copying python data & objects from a cluster of Web workers to another cluster of task queue workers is not worth it.
Another problem is the good old CGI environ design. I can't help to ask? Why?
Every HTTP header is transfered via envion, and capitalized with a HTTP_ prefix e.g. HTTP_HOST. There's some serious information loss here.
1. Actual header string case
2. header order
Since WSGI is higher level framework, I think it's time for us to deliver the original header status in a SortedDict.
Again, as a newbie advice, we should take this chance of integrating PEP 3156 with a deadly simple WSGI 3.0 design:
def application(request):
ip = request.remote_ip
length = request.headers["Content-Length"]
request.write("<html>done.</html>")
request.close()
db.log(length) # some post-response actions.