xref: /unit/test/python/variables/wsgi.py (revision 603:a11b80dedc6b)
1def application(environ, start_response):
2
3    content_length = int(environ.get('CONTENT_LENGTH', 0))
4    body = bytes(environ['wsgi.input'].read(content_length))
5
6    start_response('200', [
7        ('Content-Type', environ.get('CONTENT_TYPE')),
8        ('Content-Length', str(len(body))),
9        ('Request-Method', environ.get('REQUEST_METHOD')),
10        ('Request-Uri', environ.get('REQUEST_URI')),
11        ('Http-Host', environ.get('HTTP_HOST')),
12        ('Server-Protocol', environ.get('SERVER_PROTOCOL')),
13        ('Custom-Header', environ.get('HTTP_CUSTOM_HEADER')),
14        ('Wsgi-Version', str(environ['wsgi.version'])),
15        ('Wsgi-Url-Scheme', environ['wsgi.url_scheme']),
16        ('Wsgi-Multithread', str(environ['wsgi.multithread'])),
17        ('Wsgi-Multiprocess', str(environ['wsgi.multiprocess'])),
18        ('Wsgi-Run-Once', str(environ['wsgi.run_once']))
19    ])
20    return [body]
21