On Fri, Sep 17, 2010 at 2:06 PM, Armin Ronacher <span dir="ltr">&lt;<a href="mailto:armin.ronacher@active-4.com">armin.ronacher@active-4.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi,<div class="im"><br>
<br>
On 9/17/10 7:43 PM, Ian Bicking wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I&#39;m also not sure what motivated this particular change, but I don&#39;t<br>
have any opinion one way or the other.<br>
</blockquote></div>
Motivation is that WSGI wants servers to do something like this:<br>
<br>
   if len(iterable) == 1 and content_length_header_missing:<br>
       headers.append((&#39;Content-Length&#39;, str(len(iterable[0])))<br>
<br>
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.<br>


<br>
Even the piglatin middleware from the PEP 333 did not check the content length if I remember correctly.<br></blockquote><div><br>OK, so maybe it should just be clarified:<br><br>* 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 headers).<br>

<br>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&#39;s perfectly reasonable to set it -- but certainly the server doesn&#39;t &quot;own&quot; that header (or any other, except maybe some connection-related headers?).<br>

</div></div><br>-- <br>Ian Bicking  |  <a href="http://blog.ianbicking.org">http://blog.ianbicking.org</a><br>