Web Gateway Modules

wsgiref.validate

Wraps a WSGI application with runtime checks for aspects of the WSGI contract. It can detect invalid status, headers or non-byte body chunks, but passing does not prove complete correctness or security. Test with a valid synthetic environment and close the returned iterator.

Formal Syntax & Structure

python syntaxpython
import wsgiref.validate

Return Value

module

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

Working Example

Example Snippetpython
from wsgiref.validate import validatorfrom wsgiref.util import setup_testing_defaultsdef app(env, start_response):    start_response("200 OK", [("Content-Type", "text/plain")])    return [b"ok"]env = {"QUERY_STRING": ""}setup_testing_defaults(env)response = validator(app)(env, lambda s, h, exc_info=None: lambda data: None)try:    print(b"".join(response))finally:    response.close()
Python Reference