summaryrefslogtreecommitdiffhomepage
path: root/test/python/delayed
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2019-11-14 17:15:29 +0300
committerAndrei Zeliankou <zelenkov@nginx.com>2019-11-14 17:15:29 +0300
commitc7726c0eb1157ea90cd0e6eb1d0f29587f2148c0 (patch)
tree6d03c3dc70145486eb4da382eb157c780ff1c4c4 /test/python/delayed
parentefb461c0e1dcd15577a6a072668990facc5533f6 (diff)
downloadunit-c7726c0eb1157ea90cd0e6eb1d0f29587f2148c0.tar.gz
unit-c7726c0eb1157ea90cd0e6eb1d0f29587f2148c0.tar.bz2
Tests: proxy tests.
Diffstat (limited to 'test/python/delayed')
-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 []