Request Class — flask Architecture
Architecture documentation for the Request class in wrappers.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD eae007fa_ef39_ed97_113d_df4ad5001c0e["Request"] fb9bd0c5_9d0a_c235_58cf_8d691dde64fb["wrappers.py"] eae007fa_ef39_ed97_113d_df4ad5001c0e -->|defined in| fb9bd0c5_9d0a_c235_58cf_8d691dde64fb 3f88a364_b80b_b41a_62e5_2f777bb638ab["max_content_length()"] eae007fa_ef39_ed97_113d_df4ad5001c0e -->|method| 3f88a364_b80b_b41a_62e5_2f777bb638ab 59135935_6f4b_45a5_e08c_06364198ef45["max_form_memory_size()"] eae007fa_ef39_ed97_113d_df4ad5001c0e -->|method| 59135935_6f4b_45a5_e08c_06364198ef45 f6640fec_4973_5c70_8c93_1e49518e40b6["max_form_parts()"] eae007fa_ef39_ed97_113d_df4ad5001c0e -->|method| f6640fec_4973_5c70_8c93_1e49518e40b6 8c645767_75a9_1338_69c3_1e85a31a82b2["endpoint()"] eae007fa_ef39_ed97_113d_df4ad5001c0e -->|method| 8c645767_75a9_1338_69c3_1e85a31a82b2 53d45141_828e_ea9a_7cbc_ddf952818e95["blueprint()"] eae007fa_ef39_ed97_113d_df4ad5001c0e -->|method| 53d45141_828e_ea9a_7cbc_ddf952818e95 fabd495b_0db3_795d_c888_c583c9046a27["blueprints()"] eae007fa_ef39_ed97_113d_df4ad5001c0e -->|method| fabd495b_0db3_795d_c888_c583c9046a27 5f88d5d7_124f_d106_8824_7973e1208398["_load_form_data()"] eae007fa_ef39_ed97_113d_df4ad5001c0e -->|method| 5f88d5d7_124f_d106_8824_7973e1208398 1680f09c_0655_53f5_4345_25fe6c44e2d9["on_json_loading_failed()"] eae007fa_ef39_ed97_113d_df4ad5001c0e -->|method| 1680f09c_0655_53f5_4345_25fe6c44e2d9
Relationship Graph
Source Code
src/flask/wrappers.py lines 18–219
class Request(RequestBase):
"""The request object used by default in Flask. Remembers the
matched endpoint and view arguments.
It is what ends up as :class:`~flask.request`. If you want to replace
the request object used you can subclass this and set
:attr:`~flask.Flask.request_class` to your subclass.
The request object is a :class:`~werkzeug.wrappers.Request` subclass and
provides all of the attributes Werkzeug defines plus a few Flask
specific ones.
"""
json_module: t.Any = json
#: The internal URL rule that matched the request. This can be
#: useful to inspect which methods are allowed for the URL from
#: a before/after handler (``request.url_rule.methods``) etc.
#: Though if the request's method was invalid for the URL rule,
#: the valid list is available in ``routing_exception.valid_methods``
#: instead (an attribute of the Werkzeug exception
#: :exc:`~werkzeug.exceptions.MethodNotAllowed`)
#: because the request was never internally bound.
#:
#: .. versionadded:: 0.6
url_rule: Rule | None = None
#: A dict of view arguments that matched the request. If an exception
#: happened when matching, this will be ``None``.
view_args: dict[str, t.Any] | None = None
#: If matching the URL failed, this is the exception that will be
#: raised / was raised as part of the request handling. This is
#: usually a :exc:`~werkzeug.exceptions.NotFound` exception or
#: something similar.
routing_exception: HTTPException | None = None
_max_content_length: int | None = None
_max_form_memory_size: int | None = None
_max_form_parts: int | None = None
@property
def max_content_length(self) -> int | None:
"""The maximum number of bytes that will be read during this request. If
this limit is exceeded, a 413 :exc:`~werkzeug.exceptions.RequestEntityTooLarge`
error is raised. If it is set to ``None``, no limit is enforced at the
Flask application level. However, if it is ``None`` and the request has
no ``Content-Length`` header and the WSGI server does not indicate that
it terminates the stream, then no data is read to avoid an infinite
stream.
Each request defaults to the :data:`MAX_CONTENT_LENGTH` config, which
defaults to ``None``. It can be set on a specific ``request`` to apply
the limit to that specific view. This should be set appropriately based
on an application's or view's specific needs.
.. versionchanged:: 3.1
This can be set per-request.
.. versionchanged:: 0.6
This is configurable through Flask config.
"""
if self._max_content_length is not None:
return self._max_content_length
if not current_app:
return super().max_content_length
return current_app.config["MAX_CONTENT_LENGTH"] # type: ignore[no-any-return]
@max_content_length.setter
def max_content_length(self, value: int | None) -> None:
self._max_content_length = value
@property
def max_form_memory_size(self) -> int | None:
"""The maximum size in bytes any non-file form field may be in a
``multipart/form-data`` body. If this limit is exceeded, a 413
:exc:`~werkzeug.exceptions.RequestEntityTooLarge` error is raised. If it
is set to ``None``, no limit is enforced at the Flask application level.
Domain
Defined In
Source
Frequently Asked Questions
What is the Request class?
Request is a class in the flask codebase, defined in src/flask/wrappers.py.
Where is Request defined?
Request is defined in src/flask/wrappers.py at line 18.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free