[Web-SIG] When must applications call the WSGI start_response callable.
Jim Fulton
jim at zope.com
Thu Dec 15 21:59:04 CET 2005
James Y Knight wrote:
> On Dec 15, 2005, at 3:01 PM, Jim Fulton wrote:
>
>> Normally an application will call the start_response callable when the
>> application is called or when the result iterator is constructed, as
>> shown in the first 2 examples. An application, or more commonly, a
>> middleware component that provides it's own thread management might
>> delay starting the response. A server should not begin iterating
>> over the result until the start_response callable has been called."
>
>
> But it's my understanding that this is valid:
>
> def test_calledStartResponseLate(self):
> def application(environ, start_response):
> start_response("200 OK", {})
> yield "Foo"
>
> start_response is called _inside_ the first iteration of the result. So
> the server has to iterate at least once, even if start_response was not
> called...
>
> I was led to believe this was a valid thing to do from the following
> wording:
>
>> (Note: the application must invoke the start_response() callable
>> before the iterable yields its first body string, so that the server
>> can send the headers before any body content. However, this
>> invocation may be performed by the iterable's first iteration, so
>> servers must not assume that start_response() has been called before
>> they begin iterating over the iterable.)
Aargh, I didn't see that, despite looking for it. I said I may have missed
it.
Hm.
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Web-SIG
mailing list