PEP: XXXX Title: Python Web Server Gateway Interface v1.1 Version: $Revision: 71593 $ Last-Modified: $Date: 2009-04-13 13:58:19 -0700 (Mon, 13 Apr 2009) $ Author: Armin Ronacher <firstname.lastname@example.org> Discussions-To: Python Web-SIG <email@example.com> Status: Draft Type: Informational Content-Type: text/x-rst Created: 19-Sep-2009 Abstract ======== This document specifies a proposed standard interface between web servers and Python web applications or frameworks, to promote web application portability across a variety of web servers. It superseeds :pep:`0333` for unicode aware applications for both Python 2.x and Python 3. Rationale and Goals =================== Starting with Python 3.0, Python now features two distinct string types for text and binary data. This also made it necessary to specify a new revision of WSGI that is based on unicode. Specification Overview ====================== This specification only highlights the differences between WSGI 1.0 and WSGI 1.1. Differences to WSGI 1.0 ======================= Headers and Environment ----------------------- The WSGI server is required to process the headers as `latin1` (also known as `iso-8859-1`). This also affects the request line that specifies the request path and HTTP method. The keys of the WSGI dictionary are unicode values. The values of the WSGI dictionary that contain text are unicode as well. This affects both the headers and standard CGI variables. The version information in the WSGI environment (`wsgi.version`) is ``(1, 1)``. URL Decoding ------------ For the keys ``SCRIPT_NAME``, ``PATH_INFO`` (and ``REQUEST_URI`` if available) the server has to use the following algorithm for decoding: - it decodes all values as `utf-8`. - if that fails, it decodes all values as `iso-8859-1`. The latter will always work. The encoding the server used to decode the value is then stored in `wsgi.uri_encoding`. The application MUST use this value to decode the `QUERY_STRING` as well. URL Encoding ------------ If the application encodes URLs it is required to encode the URLs to `utf-8`, independent of the value of the `wsgi.uri_encoding`. write() deprecated ------------------ The WSGI server has to provide a `write()` function that works like exactly like the function in WSGI 1.0, but it is required to emit a deprecation warning to warns about this function being obsolete. `write()` will be remove in WSGI 2.0, which will be based on WSGI 1.1.