Request
class¶
Importing the Request
from esmerald
is as simple as:
from esmerald import Request
esmerald.Request
¶
Request(scope, receive=empty_receive, send=empty_send)
Bases: Request
Source code in esmerald/requests.py
23 24 25 26 27 28 29 30 |
|
media
property
¶
media
Gathers the information about the media for the request and returns a dictionary type.
content_type
property
¶
content_type
Get the content type of the request.
RETURNS | DESCRIPTION |
---|---|
str
|
Tuple[str, Dict[str, str]]: The content type as a tuple containing a string |
str
|
and a dictionary of parameters. |
global_settings
property
¶
global_settings
Access to the global settings via request.global_settings
.
set_session
¶
set_session(value)
Sets the value of a request session by passing a dictionary.
Source code in lilya/_internal/_connection.py
177 178 179 180 181 |
|
clear_session
¶
clear_session()
Clears the scope session.
Source code in lilya/_internal/_connection.py
183 184 185 186 187 |
|
is_secure
¶
is_secure()
Check if the connection is secure (HTTPS).
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the connection is secure (HTTPS), False otherwise.
TYPE:
|
Source code in lilya/_internal/_connection.py
189 190 191 192 193 194 195 196 |
|
url_for
¶
url_for(name, /, **path_params)
Source code in lilya/_internal/_connection.py
203 204 |
|
add_cleanup
¶
add_cleanup(fn)
Source code in lilya/requests.py
73 74 |
|
receive
async
¶
receive()
The receive channel of the request.
RETURNS | DESCRIPTION |
---|---|
Message
|
the message.
TYPE:
|
Source code in lilya/requests.py
108 109 110 111 112 113 114 115 116 117 118 119 |
|
sniff
async
¶
sniff()
The receive channel of the request.
RETURNS | DESCRIPTION |
---|---|
Message
|
the message.
TYPE:
|
Source code in lilya/requests.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
send
async
¶
send(message)
The send of the request.
Source code in lilya/requests.py
139 140 141 142 143 144 |
|
stream
async
¶
stream()
Stream the request body in asynchronous chunks.
YIELDS | DESCRIPTION |
---|---|
AsyncGenerator[bytes, None]
|
AsyncGenerator[bytes, None]: Bytes representing chunks of the request body. |
Source code in lilya/requests.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
body
async
¶
body()
Read the entire request body.
RETURNS | DESCRIPTION |
---|---|
bytes
|
The request body as bytes.
TYPE:
|
Source code in lilya/requests.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
text
async
¶
text()
Returns the body in as a string.
Source code in lilya/requests.py
237 238 239 240 241 242 243 244 245 |
|
data
async
¶
data(*, raise_exception=False)
Returns any form or multipart forms from the request or simply returns a JSON or text/plain format.
Source code in lilya/requests.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
form
¶
form(*, max_files=1000, max_fields=1000)
Get the form data from the request.
PARAMETER | DESCRIPTION |
---|---|
max_files
|
Maximum number of files allowed in the form data.
TYPE:
|
max_fields
|
Maximum number of fields allowed in the form data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AsyncResourceHandler[FormData]
|
AsyncResourceHandler[FormData]: Awaiting or using this object will |
AsyncResourceHandler[FormData]
|
return the parsed form data. |
Source code in lilya/requests.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
close
async
¶
close()
Close the request and associated resources.
This includes closing the form data, if any.
Source code in lilya/requests.py
328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
is_disconnected
async
¶
is_disconnected()
Check if the client is disconnected.
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the client is disconnected, False otherwise.
TYPE:
|
Source code in lilya/requests.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
|
send_push_promise
async
¶
send_push_promise(path)
Send a push promise for the specified path.
PARAMETER | DESCRIPTION |
---|---|
path
|
The path for which to send the push promise.
TYPE:
|
Source code in lilya/requests.py
362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
json
async
¶
json()
Source code in esmerald/requests.py
60 61 62 63 64 65 66 67 |
|
path_for
¶
path_for(__name, **path_params)
Source code in esmerald/requests.py
69 70 71 |
|