[Web-SIG] PEP 444 (aka Web3)
ianb at colorstudy.com
Fri Sep 17 20:14:29 CEST 2010
On Fri, Sep 17, 2010 at 2:06 PM, Armin Ronacher <armin.ronacher at active-4.com
> On 9/17/10 7:43 PM, Ian Bicking wrote:
>> I'm also not sure what motivated this particular change, but I don't
>> have any opinion one way or the other.
> Motivation is that WSGI wants servers to do something like this:
> if len(iterable) == 1 and content_length_header_missing:
> headers.append(('Content-Length', str(len(iterable)))
> However not everybody was doing that and some applications were setting a
> content length header or not. If a content length header was not set some
> middlewares that changed content worked properly even though they did not
> check the header. The idea is that with web3 every tool in the chain is
> supposed to look for that header and update it appropriately.
> Even the piglatin middleware from the PEP 333 did not check the content
> length if I remember correctly.
OK, so maybe it should just be clarified:
* Middleware and servers should not modify or add Content-Length, Date, or
other headers unless they have reason to do so, and they must ensure that
the response is valid (e.g., there should never be two Content-Length
It still seems reasonable that *if* there is no Content-Length, and the
server can guess easily enough (mostly it is returned an actual list/tuple
that we know can be introspected fast and without side effects), then it's
perfectly reasonable to set it -- but certainly the server doesn't "own"
that header (or any other, except maybe some connection-related headers?).
Ian Bicking | http://blog.ianbicking.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Web-SIG