[New-bugs-announce] [issue21890] wsgiref.simple_server doesn't accept empty bytes before start_response is called
Robin Schoonover
report at bugs.python.org
Tue Jul 1 05:15:10 CEST 2014
New submission from Robin Schoonover:
Consider this paragraph of PEP3333, referring to headers obtained
via start_response, emphasis mine:
Instead, it must store them for the server or gateway to
transmit only after the first iteration of the application
return value that yields a *non-empty bytestring*, or upon
the application's first invocation of the write() callable.
This means that an WSGI app such as this should be valid, because the
yielded bytes pre-start_response are empty:
def application(environ, start_response):
yield b''
start_response("200 OK", [("Content-Type", "text/plain")])
yield b'Hello, World.\n'
However, in wsgiref's simple server, this fails:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/local/lib/python3.4/wsgiref/handlers.py", line 269, in write
raise AssertionError("write() before start_response()")
AssertionError: write() before start_response()
----------
components: Library (Lib)
messages: 222005
nosy: pje, rschoon
priority: normal
severity: normal
status: open
title: wsgiref.simple_server doesn't accept empty bytes before start_response is called
type: behavior
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21890>
_______________________________________
More information about the New-bugs-announce
mailing list