summaryrefslogtreecommitdiffhomepage
path: root/test/python/chunked/wsgi.py
blob: 23ee81fcf582c548c7e02aa0666aac6e79a96ff1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def application(environ, start_response):

    content_length = int(environ.get('CONTENT_LENGTH', 0))
    body = bytes(environ['wsgi.input'].read(content_length))

    header_transfer = environ.get('HTTP_X_TRANSFER')
    header_length = environ.get('HTTP_X_LENGTH')

    headers = []

    if header_length:
        headers.append(('Content-Length', '0'))

    if header_transfer:
        headers.append(('Transfer-Encoding', header_transfer))

    start_response('200', headers)
    return [body]