Request
class¶
Warning
The current page still doesn't have a translation for this language.
But you can help translating it: Contributing.
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
PARAMETER | DESCRIPTION |
---|---|
scope
|
TYPE:
|
receive
|
TYPE:
|
send
|
TYPE:
|
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.
PARAMETER | DESCRIPTION |
---|---|
value
|
TYPE:
|
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 |
|
receive
async
¶
receive()
The receive channel of the request.
RETURNS | DESCRIPTION |
---|---|
Message
|
the message.
TYPE:
|
Source code in lilya/requests.py
96 97 98 99 100 101 102 103 104 105 106 107 |
|
sniff
async
¶
sniff()
The receive channel of the request.
RETURNS | DESCRIPTION |
---|---|
Message
|
the message.
TYPE:
|
Source code in lilya/requests.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
send
async
¶
send(message)
The send of the request.
PARAMETER | DESCRIPTION |
---|---|
message
|
TYPE:
|
Source code in lilya/requests.py
127 128 129 130 131 132 |
|
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
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
body
async
¶
body()
Read the entire request body.
RETURNS | DESCRIPTION |
---|---|
bytes
|
The request body as bytes.
TYPE:
|
Source code in lilya/requests.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
text
async
¶
text()
Returns the body in as a string.
Source code in lilya/requests.py
225 226 227 228 229 230 231 232 233 |
|
data
async
¶
data(*, raise_exception=False)
Returns any form or multipart forms from the request or simply returns a JSON or text/plain format.
PARAMETER | DESCRIPTION |
---|---|
raise_exception
|
TYPE:
|
Source code in lilya/requests.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|
form
¶
form(*, max_files=1000, max_fields=1000)
Get the form data from the request.
PARAMETER | DESCRIPTION |
---|---|
max_files
|
TYPE:
|
max_fields
|
TYPE:
|
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
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
|
close
async
¶
close()
Close the request and associated resources.
This includes closing the form data, if any.
Source code in lilya/requests.py
316 317 318 319 320 321 322 323 |
|
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
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
send_push_promise
async
¶
send_push_promise(path)
Send a push promise for the specified path.
PARAMETER | DESCRIPTION |
---|---|
path
|
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
path
|
The path for which to send the push promise.
TYPE:
|
Source code in lilya/requests.py
345 346 347 348 349 350 351 352 353 354 355 356 357 |
|
json
async
¶
json()
Source code in esmerald/requests.py
60 61 62 63 64 65 66 67 |
|
path_for
¶
path_for(__name, **path_params)
PARAMETER | DESCRIPTION |
---|---|
__name
|
TYPE:
|
**path_params
|
TYPE:
|
Source code in esmerald/requests.py
69 70 71 |
|