xref: /unit/test/python/input_readline/wsgi.py (revision 1400:cbd75efbfb74)
1*1400Smax.romanov@nginx.comdef application(environ, start_response):
2*1400Smax.romanov@nginx.com    body = []
3*1400Smax.romanov@nginx.com    content_length = 0
4*1400Smax.romanov@nginx.com
5*1400Smax.romanov@nginx.com    while True:
6*1400Smax.romanov@nginx.com        l = environ['wsgi.input'].readline()
7*1400Smax.romanov@nginx.com        if not l:
8*1400Smax.romanov@nginx.com            break
9*1400Smax.romanov@nginx.com
10*1400Smax.romanov@nginx.com        body.append(l)
11*1400Smax.romanov@nginx.com        content_length += len(l)
12*1400Smax.romanov@nginx.com
13*1400Smax.romanov@nginx.com    start_response(
14*1400Smax.romanov@nginx.com        '200',
15*1400Smax.romanov@nginx.com        [
16*1400Smax.romanov@nginx.com            ('Content-Length', str(content_length)),
17*1400Smax.romanov@nginx.com            ('X-Lines-Count', str(len(body))),
18*1400Smax.romanov@nginx.com        ],
19*1400Smax.romanov@nginx.com    )
20*1400Smax.romanov@nginx.com    return body
21