Web Gateway Modules

wsgiref.util

Helpers for WSGI URL reconstruction, test environments and file-like response iteration. setup_testing_defaults fills missing environment keys for tests; it does not produce trusted production request data. shift_path_info moves one path segment into SCRIPT_NAME.

Formal Syntax & Structure

python syntaxpython
import wsgiref.util

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from wsgiref.util import setup_testing_defaults, request_urienv = {"HTTP_HOST": "example.invalid", "PATH_INFO": "/tea", "QUERY_STRING": "n=2"}setup_testing_defaults(env)print(request_uri(env))
Python Reference