summaryrefslogtreecommitdiffhomepage
path: root/test/python/delayed/wsgi.py
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-11-14 19:29:00 +0300
committerAndrei Belov <defan@nginx.com>2019-11-14 19:29:00 +0300
commit7630539c44fcb188bba03a65af34e952a81f2f38 (patch)
tree2c80f0cd315cae8079a39ba98ed89e02b5e1931a /test/python/delayed/wsgi.py
parent70c9f18b6e8b25850bce8eb1edba4d100c3e55d2 (diff)
parent0a27f137de776925a24406cf6961c550824c63a0 (diff)
downloadunit-7630539c44fcb188bba03a65af34e952a81f2f38.tar.gz
unit-7630539c44fcb188bba03a65af34e952a81f2f38.tar.bz2
Merged with the default branch.1.13.0-1
Diffstat (limited to 'test/python/delayed/wsgi.py')
-rw-r--r--test/python/delayed/wsgi.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/python/delayed/wsgi.py b/test/python/delayed/wsgi.py
new file mode 100644
index 00000000..d25e2765
--- /dev/null
+++ b/test/python/delayed/wsgi.py
@@ -0,0 +1,25 @@
+import time
+
+
+def application(environ, start_response):
+ parts = int(environ.get('HTTP_X_PARTS', 1))
+ delay = int(environ.get('HTTP_X_DELAY', 0))
+
+ content_length = int(environ.get('CONTENT_LENGTH', 0))
+ body = bytes(environ['wsgi.input'].read(content_length))
+
+ write = start_response('200', [('Content-Length', str(len(body)))])
+
+ if not body:
+ return []
+
+ step = int(len(body) / parts)
+ for i in range(0, len(body), step):
+ try:
+ write(body[i : i + step])
+ except:
+ break
+
+ time.sleep(delay)
+
+ return []