mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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
This commit is contained in:
parent
ffe431d8bd
commit
38a66adccb
8 changed files with 184 additions and 60 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue