Files
deb-python-wsgi-intercept/test/wsgi_app.py
Mehdi Abaakouk 585f919c4b process headers only when application is processed
An application can modify the headers after
start_response have been processed.

So we have to store the references of the headers list.

And write them to the client only when the application
have been processed but before we iter the body.

wsgiref and weboob already does the same thing.
2015-07-31 14:22:07 +02:00

35 lines
823 B
Python

"""
Simple WSGI applications for testing.
"""
from pprint import pformat
try:
bytes
except ImportError:
bytes = str
def simple_app(environ, start_response):
"""Simplest possible application object"""
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return [b'WSGI intercept successful!\n']
def more_interesting_app(environ, start_response):
start_response('200 OK', [('Content-type', 'text/plain')])
return [pformat(environ).encode('utf-8')]
def post_status_headers_app(environ, start_response):
headers = []
start_response('200 OK', headers)
headers.append(('Content-type', 'text/plain'))
return [b'WSGI intercept successful!\n']
def raises_app(environ, start_response):
raise TypeError("bah")