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
PARAMETER | DESCRIPTION |
---|---|
scope
|
TYPE:
|
receive
|
TYPE:
|
send
|
TYPE:
|
Source code in esmerald/requests.py
23 24 25 26 27 28 29 30 |
|
receive
property
¶
receive
Get the receive channel of the request.
RETURNS | DESCRIPTION |
---|---|
Receive
|
The receive channel.
TYPE:
|
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
176 177 178 179 180 |
|
clear_session
¶
clear_session()
Clears the scope session.
Source code in lilya/_internal/_connection.py
182 183 184 185 186 |
|
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
188 189 190 191 192 193 194 195 |
|
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
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
body
async
¶
body()
Read the entire request body.
RETURNS | DESCRIPTION |
---|---|
bytes
|
The request body as bytes.
TYPE:
|
Source code in lilya/requests.py
178 179 180 181 182 183 184 185 186 187 |
|
text
async
¶
text()
Returns the body in as a string.
Source code in lilya/requests.py
204 205 206 207 208 209 210 211 212 |
|
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
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
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
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
close
async
¶
close()
Close the request and associated resources.
This includes closing the form data, if any.
Source code in lilya/requests.py
295 296 297 298 299 300 301 302 |
|
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
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
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
324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
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 |
|