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
PARAMETER | DESCRIPTION |
---|---|
scope |
TYPE:
|
receive |
TYPE:
|
send |
TYPE:
|
Source code in starlette/requests.py
193 194 195 196 197 198 199 200 201 202 |
|
url_for
ยถ
url_for(name, /, **path_params)
PARAMETER | DESCRIPTION |
---|---|
name |
TYPE:
|
**path_params |
TYPE:
|
Source code in starlette/requests.py
176 177 178 179 |
|
stream
async
ยถ
stream()
Source code in starlette/requests.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
body
async
ยถ
body()
Source code in starlette/requests.py
232 233 234 235 236 237 238 |
|
json
async
ยถ
json()
Source code in starlette/requests.py
240 241 242 243 244 |
|
form
ยถ
form(*, max_files=1000, max_fields=1000)
PARAMETER | DESCRIPTION |
---|---|
max_files |
TYPE:
|
max_fields |
TYPE:
|
Source code in starlette/requests.py
279 280 281 282 283 284 285 286 287 |
|
close
async
ยถ
close()
Source code in starlette/requests.py
289 290 291 |
|
is_disconnected
async
ยถ
is_disconnected()
Source code in starlette/requests.py
293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
send_push_promise
async
ยถ
send_push_promise(path)
PARAMETER | DESCRIPTION |
---|---|
path |
TYPE:
|
Source code in starlette/requests.py
307 308 309 310 311 312 313 314 315 316 317 |
|