Go to the latest version of this document.

# ``twisted`.`web`.`wsgi``

module documentation
(source)

An implementation of Python Web Server Gateway Interface v1.0.1.

Class | `WSGIResource` | An `IResource` implementation which delegates responsibility for all resources hierarchically inferior to it to a WSGI application.
Class | `_ErrorStream` | File-like object instances of which are used as the value for the `'wsgi.errors'` key in the `environ` dictionary passed to the application object.
Class | `_InputStream` | File-like object instances of which are used as the value for the `'wsgi.input'` key in the `environ` dictionary passed to the application object.
Class | `_WSGIResponse` | Helper for `WSGIResource` which drives the WSGI application using a threadpool and hooks it up to the `http.Request`.
Function | `_wsgiString` | Convert `string` to a WSGI "bytes-as-unicode" string.
Function | `_wsgiStringToBytes` | Convert `string` from a WSGI "bytes-as-unicode" string to an ISO-8859-1 byte string.

def _wsgiString(string: `str | bytes`) -> `str`: (source)

Convert `string` to a WSGI "bytes-as-unicode" string.

If it's a byte string, decode as ISO-8859-1. If it's a Unicode string, round-trip it to bytes and back using ISO-8859-1 as the encoding.

Parameters
string:`str` or `bytes` | Undocumented

Returns
`str` | Undocumented

Raises
`UnicodeEncodeError` | If `string` contains non-ISO-8859-1 chars.

def _wsgiStringToBytes(string: `str`) -> `bytes`: (source)

Convert `string` from a WSGI "bytes-as-unicode" string to an ISO-8859-1 byte string.

Parameters
string:`str` | Undocumented

Returns
`bytes` | Undocumented

Raises
`UnicodeEncodeError` | If `string` contains non-ISO-8859-1 chars.