Home / Function/ max_content_length() — flask Function Reference

max_content_length() — flask Function Reference

Architecture documentation for the max_content_length() function in wrappers.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  7683fd93_343a_e8f3_82c0_11a63ff64a99["max_content_length()"]
  89f34466_fa9b_b195_2109_880341ea2121["Request"]
  7683fd93_343a_e8f3_82c0_11a63ff64a99 -->|defined in| 89f34466_fa9b_b195_2109_880341ea2121
  style 7683fd93_343a_e8f3_82c0_11a63ff64a99 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/wrappers.py lines 60–86

    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]

Subdomains

Frequently Asked Questions

What does max_content_length() do?
max_content_length() is a function in the flask codebase, defined in src/flask/wrappers.py.
Where is max_content_length() defined?
max_content_length() is defined in src/flask/wrappers.py at line 60.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free