Skip to content
Myr

rename send_file add_etags to etag

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 1936ca8 · Browse files · 2 files+23 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+23 added−4 removed

  • other:+23 added−4 removed

2 files+23 added−4 removed

modified:src/flask/helpers.py+21 added-3 removed
437 unmodified lines
438439def _prepare_send_file_kwargs(440 download_name=None,441 attachment_filename=None,442 etag=None,443 add_etags=None,444 max_age=None,445 cache_timeout=None,446 **kwargs,447):
14 unmodified lines
462 stacklevel=3,463 )464 max_age = cache_timeout465466 if add_etags is not None:467 warnings.warn(468 "The 'add_etags' parameter has been renamed to 'etag'. The old name will be"469 " removed in Flask 2.1.",470 DeprecationWarning,471 stacklevel=3,472 )473 etag = add_etags474475 if max_age is None:476 max_age = current_app.get_send_file_max_age477478 kwargs.update(479 environ=request.environ,480 download_name=download_name,481 etag=etag,482 max_age=max_age,483 use_x_sendfile=current_app.use_x_sendfile,484 response_class=current_app.response_class,485 _root_path=current_app.root_path,
7 unmodified lines
493 as_attachment=False,494 download_name=None,495 attachment_filename=None,496 conditional=True,485 add_etags=True,497 etag=True,498 add_etags=None,499 last_modified=None,500 max_age=None,501 cache_timeout=None,502):
27 unmodified lines
530 :param download_name: The default name browsers will use when saving531 the file. Defaults to the passed file name.532 :param conditional: Enable conditional and range responses based on533 request headers. Requires passing a file path and ``environ``.521 :param add_etags: Calculate an ETag for the file. Requires passing a522 file path.534 :param etag: Calculate an ETag for the file, which requires passing535 a file path. Can also be a string to use instead.536 :param last_modified: The last modified time to send for the file,537 in seconds. If not provided, it will try to detect it from the538 file path.539 :param max_age: How long the client should cache the file, in
9 unmodified lines
549 ``max_age`` replaces the ``cache_timeout`` parameter.550 ``conditional`` is enabled and ``max_age`` is not set by551 default.552553 .. versionchanged:: 2.0.0554 ``etag`` replaces the ``add_etags`` parameter. It can be a555 string to use instead of generating one.556557 .. versionchanged:: 2.0558 Passing a file-like object that inherits from559 :class:`~io.TextIOBase` will raise a :exc:`ValueError` rather560 than sending an empty file.
48 unmodified lines
609 as_attachment=as_attachment,610 download_name=download_name,611 attachment_filename=attachment_filename,612 conditional=conditional,613 etag=etag,614 add_etags=add_etags,615 last_modified=last_modified,616 max_age=max_age,617 cache_timeout=cache_timeout,
417 unmodified lines
modified:CHANGES.rst+2 added-1 removed
47 unmodified lines
48- ``send_file`` and ``send_from_directory`` are wrappers around the49 implementations in ``werkzeug.utils``. :pr:`3828`50- Some ``send_file`` parameters have been renamed, the old names are51 deprecated. ``attachment_filename`` is renamed to ``download_name``.52 ``cache_timeout`` is renamed to ``max_age``. :pr:`3828`52 ``cache_timeout`` is renamed to ``max_age``. ``add_etags`` is53 renamed to ``etag``. :pr:`3828, 3883`54- ``send_file`` passes ``download_name`` even if55 ``as_attachment=False`` by using ``Content-Disposition: inline``.56 :pr:`3828`57- ``send_file`` sets ``conditional=True`` and ``max_age=None`` by
1020 unmodified lines