class documentation

class WSGITransport(BaseTransport): (source)

View In Hierarchy

A custom transport that handles sending requests directly to an WSGI app. The simplest way to use this functionality is to use the `app` argument. ``` client = httpx.Client(app=app) ``` Alternatively, you can setup the transport instance explicitly. This allows you to include any additional configuration arguments specific to the WSGITransport class: ``` transport = httpx.WSGITransport( app=app, script_name="/submount", remote_addr="1.2.3.4" ) client = httpx.Client(transport=transport) ``` Arguments: * `app` - The WSGI application. * `raise_app_exceptions` - Boolean indicating if exceptions in the application should be raised. Default to `True`. Can be set to `False` for use cases such as testing the content of a client 500 response. * `script_name` - The root path on which the WSGI application should be mounted. * `remote_addr` - A string indicating the client IP of incoming requests. ```

Method __init__ Undocumented
Method handle_request Send a single HTTP request and return a response.
Instance Variable app Undocumented
Instance Variable raise_app_exceptions Undocumented
Instance Variable remote_addr Undocumented
Instance Variable script_name Undocumented
Instance Variable wsgi_errors Undocumented

Inherited from BaseTransport:

Method __enter__ Undocumented
Method __exit__ Undocumented
Method close Undocumented
def __init__(self, app, raise_app_exceptions=True, script_name='', remote_addr='127.0.0.1', wsgi_errors=None): (source)

Undocumented

Parameters
app:WSGIApplicationUndocumented
raise_app_exceptions:boolUndocumented
script_name:strUndocumented
remote_addr:strUndocumented
wsgi_errors:typing.Optional[typing.TextIO]Undocumented
def handle_request(self, request): (source)

Send a single HTTP request and return a response. Developers shouldn't typically ever need to call into this API directly, since the Client class provides all the higher level user-facing API niceties. In order to properly release any network resources, the response stream should *either* be consumed immediately, with a call to `response.stream.read()`, or else the `handle_request` call should be followed with a try/finally block to ensuring the stream is always closed. Example usage: with httpx.HTTPTransport() as transport: req = httpx.Request( method=b"GET", url=(b"https", b"www.example.com", 443, b"/"), headers=[(b"Host", b"www.example.com")], ) resp = transport.handle_request(req) body = resp.stream.read() print(resp.status_code, resp.headers, body) Takes a `Request` instance as the only argument. Returns a `Response` instance.

Parameters
request:RequestUndocumented
Returns
ResponseUndocumented

Undocumented

raise_app_exceptions = (source)

Undocumented

remote_addr = (source)

Undocumented

script_name = (source)

Undocumented

wsgi_errors = (source)

Undocumented