aboutsummaryrefslogtreecommitdiff
path: root/dummyserver/handlers.py
diff options
context:
space:
mode:
authorSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:19:33 -0700
committerSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:19:33 -0700
commit92b84b67f7b187b81dacbf1ae46d59a1d0b5b125 (patch)
treee02dc576320cdc51de3d59d899a5c70ed610e24a /dummyserver/handlers.py
parente5b66555b54a9854b340975471e8cdfa64e311f7 (diff)
downloadpython-urllib3-92b84b67f7b187b81dacbf1ae46d59a1d0b5b125.tar
python-urllib3-92b84b67f7b187b81dacbf1ae46d59a1d0b5b125.tar.gz
Imported Upstream version 1.6
Diffstat (limited to 'dummyserver/handlers.py')
-rw-r--r--dummyserver/handlers.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/dummyserver/handlers.py b/dummyserver/handlers.py
index ca809ad..ab48b53 100644
--- a/dummyserver/handlers.py
+++ b/dummyserver/handlers.py
@@ -1,6 +1,7 @@
from __future__ import print_function
import gzip
+import json
import logging
import sys
import time
@@ -120,7 +121,7 @@ class TestingApp(WSGIHandler):
return Response(status='303', headers=headers)
def keepalive(self, request):
- if request.params.get('close', '0') == '1':
+ if request.params.get('close', b'0') == b'1':
headers = [('Connection', 'close')]
return Response('Closing', headers=headers)
@@ -148,7 +149,9 @@ class TestingApp(WSGIHandler):
if encoding == 'gzip':
headers = [('Content-Encoding', 'gzip')]
file_ = BytesIO()
- gzip.GzipFile('', mode='w', fileobj=file_).write(data)
+ zipfile = gzip.GzipFile('', mode='w', fileobj=file_)
+ zipfile.write(data)
+ zipfile.close()
data = file_.getvalue()
elif encoding == 'deflate':
headers = [('Content-Encoding', 'deflate')]
@@ -161,5 +164,8 @@ class TestingApp(WSGIHandler):
data = 'garbage'
return Response(data, headers=headers)
+ def headers(self, request):
+ return Response(json.dumps(request.headers))
+
def shutdown(self, request):
sys.exit()