HTTPConnection
class
When you want to define dependencies that should be compatible with both HTTP and WebSockets, you can define a parameter that takes an HTTPConnection
instead of a Request
or a WebSocket
.
You can import it from fastapi.requests
:
from fastapi.requests import HTTPConnection
fastapi.requests.HTTPConnection
HTTPConnection(scope, receive=None)
Bases: Mapping[str, Any]
A base class for incoming HTTP connections, that is used to provide any functionality that is common to both Request
and WebSocket
.
PARAMETER | DESCRIPTION |
---|---|
scope | TYPE: |
receive | TYPE: |
Source code in starlette/requests.py
|
|
scope instance-attribute
scope = scope
app property
app
url property
url
base_url property
base_url
headers property
headers
query_params property
query_params
path_params property
path_params
cookies property
cookies
client property
client
session property
session
auth property
auth
user property
user
state property
state
url_for
url_for(__name, **path_params)
PARAMETER | DESCRIPTION |
---|---|
__name | TYPE: |
**path_params | TYPE: |
Source code in starlette/requests.py
|
|