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(<span data-autorefs-optional="fastapi.requests.HTTPConnection(scope)">scope</span>, <span data-autorefs-optional="fastapi.requests.HTTPConnection(receive)">receive</span>=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
71 72 73 |
|
url_for
¶
url_for(<span data-autorefs-optional="fastapi.requests.HTTPConnection.url_for(name)">name</span>, /, <span data-autorefs-optional="fastapi.requests.HTTPConnection.url_for(**path_params)">**path_params</span>)
PARAMETER | DESCRIPTION |
---|---|
name
|
TYPE:
|
**path_params
|
TYPE:
|
Source code in starlette/requests.py
185 186 187 188 |
|