xref: /unit/test/python/variables/wsgi.py (revision 1848:4bd548074e2c)
1552Szelenkov@nginx.comdef application(environ, start_response):
2552Szelenkov@nginx.com
3552Szelenkov@nginx.com    content_length = int(environ.get('CONTENT_LENGTH', 0))
4552Szelenkov@nginx.com    body = bytes(environ['wsgi.input'].read(content_length))
5552Szelenkov@nginx.com
6*1848Szelenkov@nginx.com    start_response(
7*1848Szelenkov@nginx.com        '200',
8*1848Szelenkov@nginx.com        [
9*1848Szelenkov@nginx.com            ('Content-Type', environ.get('CONTENT_TYPE')),
10*1848Szelenkov@nginx.com            ('Content-Length', str(len(body))),
11*1848Szelenkov@nginx.com            ('Request-Method', environ.get('REQUEST_METHOD')),
12*1848Szelenkov@nginx.com            ('Request-Uri', environ.get('REQUEST_URI')),
13*1848Szelenkov@nginx.com            ('Http-Host', environ.get('HTTP_HOST')),
14*1848Szelenkov@nginx.com            ('Server-Protocol', environ.get('SERVER_PROTOCOL')),
15*1848Szelenkov@nginx.com            ('Server-Software', environ.get('SERVER_SOFTWARE')),
16*1848Szelenkov@nginx.com            ('Custom-Header', environ.get('HTTP_CUSTOM_HEADER')),
17*1848Szelenkov@nginx.com            ('Wsgi-Version', str(environ['wsgi.version'])),
18*1848Szelenkov@nginx.com            ('Wsgi-Url-Scheme', environ['wsgi.url_scheme']),
19*1848Szelenkov@nginx.com            ('Wsgi-Multithread', str(environ['wsgi.multithread'])),
20*1848Szelenkov@nginx.com            ('Wsgi-Multiprocess', str(environ['wsgi.multiprocess'])),
21*1848Szelenkov@nginx.com            ('Wsgi-Run-Once', str(environ['wsgi.run_once'])),
22*1848Szelenkov@nginx.com        ],
23*1848Szelenkov@nginx.com    )
24552Szelenkov@nginx.com    return [body]
25