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
201 202 203 204 205 206 207 208 |
|
url_for
¶
url_for(name, /, **path_params)
PARAMETER | DESCRIPTION |
---|---|
name
|
TYPE:
|
**path_params
|
TYPE:
|
Source code in starlette/requests.py
182 183 184 185 186 187 |
|
stream
async
¶
stream()
Source code in starlette/requests.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
body
async
¶
body()
Source code in starlette/requests.py
238 239 240 241 242 243 244 |
|
json
async
¶
json()
Source code in starlette/requests.py
246 247 248 249 250 |
|
form
¶
form(
*,
max_files=1000,
max_fields=1000,
max_part_size=1024 * 1024
)
PARAMETER | DESCRIPTION |
---|---|
max_files
|
TYPE:
|
max_fields
|
TYPE:
|
max_part_size
|
TYPE:
|
Source code in starlette/requests.py
287 288 289 290 291 292 293 294 295 296 |
|
close
async
¶
close()
Source code in starlette/requests.py
298 299 300 |
|
is_disconnected
async
¶
is_disconnected()
Source code in starlette/requests.py
302 303 304 305 306 307 308 309 310 311 312 313 314 |
|
send_push_promise
async
¶
send_push_promise(path)
PARAMETER | DESCRIPTION |
---|---|
path
|
TYPE:
|
Source code in starlette/requests.py
316 317 318 319 320 321 322 |
|