diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-03 18:41:49 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-03 18:41:49 (GMT) |
commit | 38a66adccbef4a2b2e0ad57024a2398939f47ec2 (patch) | |
tree | b5663d1f8cd3f844cddba6794d0cbc262c5cc4db /Doc | |
parent | ffe431d8bda82db8e478930fc46a0764fcbe879b (diff) | |
download | cpython-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 'Doc')
-rw-r--r-- | Doc/library/wsgiref.rst | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Doc/library/wsgiref.rst b/Doc/library/wsgiref.rst index fcfe769..e2eb3b6 100644 --- a/Doc/library/wsgiref.rst +++ b/Doc/library/wsgiref.rst @@ -122,13 +122,13 @@ parameter expect a WSGI-compliant dictionary to be supplied; please see def simple_app(environ, start_response): setup_testing_defaults(environ) - status = '200 OK' - headers = [('Content-type', 'text/plain')] + status = b'200 OK' + headers = [(b'Content-type', b'text/plain; charset=utf-8')] start_response(status, headers) - ret = ["%s: %s\n" % (key, value) - for key, value in environ.iteritems()] + ret = [("%s: %s\n" % (key, value)).encode("utf-8") + for key, value in environ.items()] return ret httpd = make_server('', 8000, simple_app) @@ -161,7 +161,7 @@ also provides these miscellaneous utilities: Example usage:: - from StringIO import StringIO + from io import StringIO from wsgiref.util import FileWrapper # We're using a StringIO-buffer for as the file-like object @@ -416,13 +416,13 @@ Paste" library. # Our callable object which is intentionally not compliant to the # standard, so the validator is going to break def simple_app(environ, start_response): - status = '200 OK' # HTTP Status - headers = [('Content-type', 'text/plain')] # HTTP Headers + status = b'200 OK' # HTTP Status + headers = [(b'Content-type', b'text/plain')] # HTTP Headers start_response(status, headers) # This is going to break because we need to return a list, and # the validator is going to inform us - return "Hello World" + return b"Hello World" # This is the application wrapped in a validator validator_app = validator(simple_app) @@ -509,7 +509,7 @@ input, output, and error streams. .. method:: BaseHandler._write(data) - Buffer the string *data* for transmission to the client. It's okay if this + Buffer the bytes *data* for transmission to the client. It's okay if this method actually transmits the data; :class:`BaseHandler` just separates write and flush operations for greater efficiency when the underlying system actually has such a distinction. @@ -712,12 +712,12 @@ This is a working "Hello World" WSGI application:: # is a dictionary containing CGI-style envrironment variables and the # second variable is the callable object (see PEP333) def hello_world_app(environ, start_response): - status = '200 OK' # HTTP Status - headers = [('Content-type', 'text/plain')] # HTTP Headers + status = b'200 OK' # HTTP Status + headers = [(b'Content-type', b'text/plain; charset=utf-8')] # HTTP Headers start_response(status, headers) # The returned object is going to be printed - return ["Hello World"] + return [b"Hello World"] httpd = make_server('', 8000, hello_world_app) print("Serving on port 8000...") |