def respond(self):
"""Process the current request."""
response = self.req.server.wsgi_app(self.env, self.start_response)
try:
for chunk in response:
# "The start_response callable must not actually transmit
# the response headers. 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 string, or upon the application's first
# invocation of the write() callable." (PEP 333)
if chunk:
if not isinstance(chunk, binary_type):
raise ValueError("WSGI Applications must yield bytes")
self.write(chunk)
finally:
if hasattr(response, "close"):
response.close()
评论列表
文章目录