Added MAX_CONTENT_LENGTH config key
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parent f8f8463 · Browse files · 4 files·+18 added−1 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+18 added−1 removed
- other:+18 added−1 removed
Provenance
- Commit
b1790cc- Tree
36ee238- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
f8f8463
4 files changed+18 added−1 removed
modified:docs/config.rst+6 added
60 unmodified lines61 ``USE_X_SENDFILE`` enable/disable x-sendfile62 ``LOGGER_NAME`` the name of the logger63 ``SERVER_NAME`` the name of the server. Required for64 subdomain support (eg: ``'localhost'``)65+``MAX_CONTENT_LENGTH`` If set to a value in bytes, Flask will66+ reject incoming requests with a67+ content length greater than this by68+ returning a 413 status code.69 =============================== =========================================70 71 .. admonition:: More on ``SERVER_NAME``72 19 unmodified lines92 93 .. versionadded:: 0.594 ``SERVER_NAME``95 96+.. versionadded:: ``MAX_CONTENT_LENGTH``97+98 Configuring from Files99 ----------------------100 101 Configuration becomes more useful if you can configure from a file, and126 unmodified linesmodified:flask/app.py+2 added-1 removed
191 unmodified lines192 'SESSION_COOKIE_NAME': 'session',193 'PERMANENT_SESSION_LIFETIME': timedelta(days=31),194 'USE_X_SENDFILE': False,195 'LOGGER_NAME': None,196- 'SERVER_NAME': None196+ 'SERVER_NAME': None,197+ 'MAX_CONTENT_LENGTH': None198 })199 200 def __init__(self, import_name, static_path=None):201 _PackageBoundObject.__init__(self, import_name)656 unmodified linesmodified:flask/wrappers.py+8 added
11 unmodified lines12 from werkzeug import Request as RequestBase, Response as ResponseBase, \13 cached_property14 15 from .helpers import json, _assert_have_json16+from .globals import _request_ctx_stack17 18 19 class Request(RequestBase):20 """The request object used by default in flask. Remembers the21 unmodified lines42 #: something similar.43 routing_exception = None44 45 @property46+ def max_content_length(self):47+ """Read-only view of the `MAX_CONTENT_LENGTH` config key."""48+ ctx = _request_ctx_stack.top49+ if ctx is not None:50+ return ctx.app.config['MAX_CONTENT_LENGTH']51+52+ @property53 def endpoint(self):54 """The endpoint that matched the request. This in combination with55 :attr:`view_args` can be used to reconstruct the same or a56 modified URL. If an exception happened when matching, this will32 unmodified linesmodified:CHANGES+2 added
19 unmodified lines20 - the :attr:`~flask.Flask.config` is now available in the templates21 as `config`.22 - context processors will no longer override values passed directly23 to the render function.24+- added the ability to limit the incoming request data with the25+ new ``MAX_CONTENT_LENGTH`` configuration value.26 27 Version 0.5.128 -------------29 98 unmodified lines