move send_file and send_from_directory to Werkzeug
The implementations were moved to Werkzeug, Flask's functions become wrappers around Werkzeug to pass some Flask-specific values. cache_timeout is renamed to max_age. SEND_FILE_MAX_AGE_DEFAULT, app.send_file_max_age_default, and app.get_send_file_max_age defaults to None. This tells the browser to use conditional requests rather than a 12 hour cache. attachment_filename is renamed to download_name, and is always sent if a name is known. Deprecate helpers.safe_join in favor of werkzeug.utils.safe_join. Removed most of the send_file tests, they're tested in Werkzeug. In the file upload example, renamed the uploaded_file view to download_file to avoid a common source of confusion.
This commit is contained in:
parent
15a49e7297
commit
dc11cdb4a4
8 changed files with 260 additions and 654 deletions
14
CHANGES.rst
14
CHANGES.rst
|
|
@ -45,6 +45,20 @@ Unreleased
|
|||
- Include ``samesite`` and ``secure`` options when removing the
|
||||
session cookie. :pr:`3726`
|
||||
- Support passing a ``pathlib.Path`` to ``static_folder``. :pr:`3579`
|
||||
- ``send_file`` and ``send_from_directory`` are wrappers around the
|
||||
implementations in ``werkzeug.utils``. :pr:`3828`
|
||||
- Some ``send_file`` parameters have been renamed, the old names are
|
||||
deprecated. ``attachment_filename`` is renamed to ``download_name``.
|
||||
``cache_timeout`` is renamed to ``max_age``. :pr:`3828`
|
||||
- ``send_file`` passes ``download_name`` even if
|
||||
``as_attachment=False`` by using ``Content-Disposition: inline``.
|
||||
:pr:`3828`
|
||||
- ``send_file`` sets ``conditional=True`` and ``max_age=None`` by
|
||||
default. ``Cache-Control`` is set to ``no-cache`` if ``max_age`` is
|
||||
not set, otherwise ``public``. This tells browsers to validate
|
||||
conditional requests instead of using a timed cache. :pr:`3828`
|
||||
- ``helpers.safe_join`` is deprecated. Use
|
||||
``werkzeug.utils.safe_join`` instead. :pr:`3828`
|
||||
|
||||
|
||||
Version 1.1.2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue