summaryrefslogtreecommitdiffstats
path: root/Lib/wsgiref/simple_server.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-01-03 18:41:49 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-01-03 18:41:49 (GMT)
commit38a66adccbef4a2b2e0ad57024a2398939f47ec2 (patch)
treeb5663d1f8cd3f844cddba6794d0cbc262c5cc4db /Lib/wsgiref/simple_server.py
parentffe431d8bda82db8e478930fc46a0764fcbe879b (diff)
downloadcpython-38a66adccbef4a2b2e0ad57024a2398939f47ec2.zip
cpython-38a66adccbef4a2b2e0ad57024a2398939f47ec2.tar.gz
cpython-38a66adccbef4a2b2e0ad57024a2398939f47ec2.tar.bz2
Issue #4718: Adapt the wsgiref package so that it actually works with Python 3.x,
in accordance with http://www.wsgi.org/wsgi/Amendments_1.0
Diffstat (limited to 'Lib/wsgiref/simple_server.py')
-rw-r--r--Lib/wsgiref/simple_server.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/wsgiref/simple_server.py b/Lib/wsgiref/simple_server.py
index a82c80a..da14144 100644
--- a/Lib/wsgiref/simple_server.py
+++ b/Lib/wsgiref/simple_server.py
@@ -111,8 +111,7 @@ class WSGIRequestHandler(BaseHTTPRequestHandler):
if length:
env['CONTENT_LENGTH'] = length
- for h in self.headers:
- k,v = h.split(':',1)
+ for k, v in self.headers.items():
k=k.replace('-','_').upper(); v=v.strip()
if k in env:
continue # skip content length, type,etc.
@@ -168,11 +167,11 @@ def demo_app(environ,start_response):
stdout = StringIO()
print("Hello world!", file=stdout)
print(file=stdout)
- h = environ.items(); h.sort()
+ h = sorted(environ.items())
for k,v in h:
print(k,'=',repr(v), file=stdout)
- start_response("200 OK", [('Content-Type','text/plain')])
- return [stdout.getvalue()]
+ start_response(b"200 OK", [(b'Content-Type',b'text/plain; charset=utf-8')])
+ return [stdout.getvalue().encode("utf-8")]
def make_server(