quart.wrappers.response module¶
-
class
quart.wrappers.response.
DataBody
(data: bytes)¶ Bases:
quart.wrappers.response.ResponseBody
-
async
convert_to_sequence
() → bytes¶
-
async
make_conditional
(begin: int, end: Optional[int], max_partial_size: Optional[int] = None) → int¶
-
async
-
class
quart.wrappers.response.
FileBody
(file_path: Union[str, os.PathLike], *, buffer_size: Optional[int] = None)¶ Bases:
quart.wrappers.response.ResponseBody
Provides an async file accessor with range setting.
The
Response.response
attribute must be async-iterable and yield bytes, which this wrapper does for a file. In addition it allows a range to be set on the file, thereby supporting conditional requests.-
buffer_size
¶ Size in bytes to load per iteration.
-
buffer_size
= 8192
-
async
convert_to_sequence
() → bytes¶
-
async
make_conditional
(begin: int, end: Optional[int], max_partial_size: Optional[int] = None) → int¶
-
-
class
quart.wrappers.response.
IOBody
(io_stream: _io.BytesIO, *, buffer_size: Optional[int] = None)¶ Bases:
quart.wrappers.response.ResponseBody
Provides an async file accessor with range setting.
The
Response.response
attribute must be async-iterable and yield bytes, which this wrapper does for a file. In addition it allows a range to be set on the file, thereby supporting conditional requests.-
buffer_size
¶ Size in bytes to load per iteration.
-
buffer_size
= 8192
-
async
convert_to_sequence
() → bytes¶
-
async
make_conditional
(begin: int, end: Optional[int], max_partial_size: Optional[int] = None) → int¶
-
-
class
quart.wrappers.response.
IterableBody
(iterable: Union[AsyncGenerator[bytes, None], Iterable])¶ Bases:
quart.wrappers.response.ResponseBody
-
async
convert_to_sequence
() → bytes¶
-
async
-
class
quart.wrappers.response.
Response
(response: Union[quart.wrappers.response.ResponseBody, AnyStr, Iterable], status: Optional[int] = None, headers: Union[dict, werkzeug.datastructures.Headers, None] = None, mimetype: Optional[str] = None, content_type: Optional[str] = None)¶ Bases:
quart.wrappers.base._BaseRequestResponse
,quart.wrappers.base.JSONMixin
This class represents a response.
It can be subclassed and the subclassed used in preference by replacing the
response_class
with your subclass.-
automatically_set_content_length
¶ If False the content length header must be provided.
-
default_status
¶ The status code to use if not provided.
-
default_mimetype
¶ The mimetype to use if not provided.
-
implicit_sequence_conversion
¶ Implicitly convert the response to a iterable in the get_data method, to allow multiple iterations.
-
property
accept_ranges
¶
-
property
access_control_allow_credentials
¶ Whether credentials can be shared by the browser to JavaScript code. As part of the preflight request it indicates whether credentials can be used on the cross origin request.
-
property
access_control_allow_headers
¶
-
property
access_control_allow_methods
¶
-
property
access_control_allow_origin
¶
-
property
access_control_expose_headers
¶
-
property
access_control_max_age
¶
-
async
add_etag
(overwrite: bool = False, weak: bool = False) → None¶
-
property
age
¶
-
property
allow
¶
-
automatically_set_content_length
= True
-
property
cache_control
¶
-
property
content_encoding
¶
-
property
content_language
¶
-
property
content_length
¶
-
property
content_location
¶
-
property
content_md5
¶
-
property
content_range
¶
-
property
content_security_policy
¶
-
property
content_security_policy_report_only
¶
-
property
content_type
¶
-
property
date
¶
-
default_mimetype
= 'text/html'
-
default_status
= 200
Delete a cookie (set to expire immediately).
-
property
expires
¶
-
async
freeze
() → None¶ Freeze this object ready for pickling.
-
async
get_data
(raw: bool = True) → AnyStr¶ Return the body data.
-
get_etag
() → Tuple[Optional[str], Optional[bool]]¶
-
implicit_sequence_conversion
= True
-
iterable_body_class
¶ alias of
IterableBody
-
property
last_modified
¶
-
property
location
¶
-
async
make_conditional
(request_range: Optional[werkzeug.datastructures.Range], max_partial_size: Optional[int] = None) → None¶ Make the response conditional to the
- Parameters
request_range – The range as requested by the request.
max_partial_size – The maximum length the server is willing to serve in a single response. Defaults to unlimited.
-
property
referrer
¶
-
property
retry_after
¶
Set a cookie in the response headers.
The arguments are the standard cookie morsels and this is a wrapper around the stdlib SimpleCookie code.
-
set_data
(data: AnyStr) → None¶ Set the response data.
This will encode using the
charset
.
-
set_etag
(etag: str, weak: bool = False) → None¶
-
property
vary
¶
-
-
class
quart.wrappers.response.
ResponseBody
¶ Bases:
abc.ABC
Base class wrapper for response body data.
This ensures that the following is possible (as Quart assumes so when returning the body to the ASGI server
- async with wrapper as response:
- async for data in response:
send(data)
-
abstract async
convert_to_sequence
() → bytes¶