Files
Chris Dent 66e2d50000 Accept an empty string from a wsgi iterator
This is allowed by the pep but the code was written such that if it
received an empty string it would not get the rest of the iterator.
This change fixes it so only None will cause the stop.

With this change an unrelated test wsgi app which was returning an
empty string needed to be fixed to return a bytestring.

Fixes #46
2017-03-05 15:02:50 +00:00

40 lines
963 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")
def empty_string_app(environ, start_response):
start_response('200 OK', [('Content-type', 'text/plain')])
return [b'', b'second']