Request
class- fastapi.Request
- scope
instance-attribute
- app
property
- url
property
- base_url
property
- headers
property
- query_params
property
- path_params
property
- cookies
property
- client
property
- session
property
- auth
property
- user
property
- state
property
- method
property
- receive
property
- url_for
- stream
async
- body
async
- json
async
- form
- close
async
- is_disconnected
async
- send_push_promise
async
- scope
- fastapi.Request
Request
class
You can declare a parameter in a path operation function or dependency to be of type Request
and then you can access the raw request object directly, without any validation, etc.
You can import it directly from fastapi
:
from fastapi import Request
Tip
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
.
fastapi.Request
Request(scope, receive=empty_receive, send=empty_send)
Bases: [HTTPConnection](https:/fastapi.tiangolo.com/zh/reference/httpconnection/#fastapi.requests.HTTPConnection "starlette.requests.HTTPConnection")
PARAMETER | DESCRIPTION |
---|---|
scope | TYPE: |
receive | TYPE: |
send | 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
method property
method
receive property
receive
url_for
url_for(__name, **path_params)
PARAMETER | DESCRIPTION |
---|---|
__name | TYPE: |
**path_params | TYPE: |
Source code in starlette/requests.py
|
|
stream async
stream()
Source code in starlette/requests.py
|
|
body async
body()
Source code in starlette/requests.py
|
|
json async
json()
Source code in starlette/requests.py
|
|
form
form(*, max_files=1000, max_fields=1000)
PARAMETER | DESCRIPTION |
---|---|
max_files | TYPE: |
max_fields | TYPE: |
Source code in starlette/requests.py
|
|
close async
close()
Source code in starlette/requests.py
|
|
is_disconnected async
is_disconnected()
Source code in starlette/requests.py
|
|
send_push_promise async
send_push_promise(path)
PARAMETER | DESCRIPTION |
---|---|
path | TYPE: |
Source code in starlette/requests.py
|
|