File: error.py

package info (click to toggle)
waitress 3.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 988 kB
  • sloc: python: 10,771; makefile: 84; sh: 25
file content (21 lines) | stat: -rw-r--r-- 653 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def app(environ, start_response):  # pragma: no cover
    cl = environ.get("CONTENT_LENGTH", None)
    if cl is not None:
        cl = int(cl)
    body = environ["wsgi.input"].read(cl)
    cl = str(len(body))
    if environ["PATH_INFO"] == "/before_start_response":
        raise ValueError("wrong")
    write = start_response(
        "200 OK", [("Content-Length", cl), ("Content-Type", "text/plain")]
    )
    if environ["PATH_INFO"] == "/after_write_cb":
        write("abc")
    if environ["PATH_INFO"] == "/in_generator":

        def foo():
            yield "abc"
            raise ValueError

        return foo()
    raise ValueError("wrong")