[Web-SIG] Future of WSGI
henry at precheur.org
Tue Nov 24 23:26:24 CET 2009
On Tue, Nov 24, 2009 at 10:50:00PM +0100, Malthe Borch wrote:
> How people use or abuse software is not our concern; but the standard
> library should not itself abuse its own abstractions.
Your assumption is that `environ` == HTTP headers. That's simply NOT the
case. A request is:
- A request line
- Some headers
- A body
The request body, the request method (GET, POST, ...), the request URL,
the HTTP version are all in `environ`.
If you really want to separate the headers from the rest you would put
another dictionary containing the headers inside `environ`. Instead WSGI
puts the headers prefixed with HTTP_ in `environ`, because that's what
CGI is doing. It might not be 100% clean, or logic, but it's SIMPLER,
there's no need to deal with nested dictionaries or other more complex
structure, and it's extensible.
> Request = namedtuple("Request", "environ body")
> Response = namedtuple("Response", "status headers iterable")
> Iterable might be "body" or "chunks" or some other term.
namedtuple is Python 2.6+: WSGI can't use it. WSGI must work w/ older
versions of Python.
More information about the Web-SIG