guillotina.request¶
- class guillotina.request.Request(scheme, method, path, query_string, raw_headers, client_max_size=1048576, send=None, receive=None, scope=None)¶
Bases:
objectGuillotina specific request type. We store potentially a lot of state onto the request object as it is essential our poor man's thread local model
- add_future(*args, **kwargs)¶
Register a future to be executed after the request has finished.
- Parameters:
name -- name of future
fut -- future to execute after request
scope -- group the futures to execute different groupings together
args -- arguments to execute future with
kwargs -- kwargs to execute future with
- property can_read_body: bool¶
Return True if request's HTTP BODY can be read, False otherwise.
- property content¶
Return raw payload stream.
- execute_futures(scope='')¶
Execute all the registered futures in a new task
- Parameters:
scope (
str) -- scoped futures to execute. Leave default for normal behavior
- get_future(name, scope='')¶
Get a registered future
- Parameters:
name (
str) -- scoped futures to execute. Leave default for normal behaviorscope (
str) -- scope name the future was registered for
- headers()¶
A case-insensitive multidict proxy with all headers.
- host()¶
Hostname of the request.
- async json(*, loads=<built-in function loads>)¶
Return BODY as JSON.
- Return type:
Any
-
matchdict:
Dict[str,str]¶ Dictionary of matched path parameters on request
- property method: str¶
Read only property for getting HTTP method.
The value is upper-cased str like 'GET', 'POST', 'PUT' etc.
- property path: str¶
The URL including PATH INFO without the host or scheme.
E.g.,
/app/blog
- path_qs()¶
The URL including PATH_INFO and the query string.
E.g, /app/blog?id=10
- query()¶
A multidict with all the variables in the query string.
- query_string()¶
The query string in the URL.
E.g., id=10
- property raw_headers¶
A sequence of pairs for all headers.
- async read()¶
Read request body if present.
Returns bytes object with full request content.
- Return type:
Union[bytes,bytearray]
- record(event_name)¶
Record event on the request
- Parameters:
event_name (
str) -- name of event
- async text()¶
Return BODY as text
- Return type:
str
- version()¶
Read only property for getting HTTP version of request.