[Web-SIG] Future of WSGI
Malthe Borch
mborch at gmail.com
Wed Nov 25 00:29:08 CET 2009
2009/11/25 Henry Precheur <henry at precheur.org>:
> Please replace '...' with actual code or at least some description of
> what it's doing. Lots of people have been trying to define a nice
> interface for these objects for YEARS. People who know a great deal
> about HTTP, and Python. And yet there's not a single implementation
> that's widely accepted as the "best of breed".
class Request(object):
def __init__(self, stream):
self.environ = read_headers_until_crlf(stream)
self.stream = stream
These headers are then "general-header", "request-header",
"entity-header". The stream is what remains.
Ian argues that the stream is part of the environment since
``CONTENT_LENGTH`` is there. However, it is not always there. It is to
be understood as a hint.
Why is this a good separation? For two reasons:
1) Everybody else does it;
2) This stream should be handled carefully throughout the WSGI
pipeline. Keeping it as a separate property helps to make this point
clear.
As an alternative to a trivial request class, I propose:
(environ, stream, [start_response])
(It seems ``start_response`` might go out altogether in a revised
specification in favor of returning a response tuple over an app
iterable).
\malthe
More information about the Web-SIG
mailing list