Skip to content
Myr

pass value directly to last_modified

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 af515cc · Browse files · 2 files+14 added−17 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+14 added−17 removed

  • tests:+9 added−8 removed
  • other:+5 added−9 removed

2 files+14 added−17 removed

modified:flask/helpers.py+5 added-9 removed
481 unmodified lines
482 :param cache_timeout: the timeout in seconds for the headers. When ``None``483 (default), this value is set by484 :meth:`~Flask.get_send_file_max_age` of485 :data:`~flask.current_app`.486 :param last_modified: the Datetime object representing timestamp for when487 the input file was last modified.486 :param last_modified: set the ``Last-Modified`` header to this value,487 a :class:`~datetime.datetime` or timestamp.488 If a file was passed, this overrides its mtime.489 """490 mtime = None491 if isinstance(filename_or_fp, string_types):492 filename = filename_or_fp
35 unmodified lines
528529 rv = current_app.response_class(data, mimetype=mimetype, headers=headers,530 direct_passthrough=True)531531 # if we know the file modification date, we can store it as532 # the time of the last modification.532 if last_modified is not None:534 if PY2:535 rv.last_modified = int(last_modified.strftime("%s"))536 else:537 rv.last_modified = last_modified.timestamp()533 rv.last_modified = last_modified534 elif mtime is not None:539 rv.last_modified = int(mtime)535 rv.last_modified = mtime536537 rv.cache_control.public = True538 if cache_timeout is None:539 cache_timeout = current_app.get_send_file_max_age(filename)
385 unmodified lines
modified:tests/test_helpers.py+9 added-8 removed
349 unmodified lines
350 rv.close()351352 def test_send_file_last_modified(self):353 app = flask.Flask(__name__)354 with app.test_request_context():355 dtm = datetime.datetime.now()356 rv = flask.send_file('static/index.html', last_modified=dtm)357 if PY2:358 assert rv.last_modified == int(dtm.strftime("%s"))359 else:360 assert rv.last_modified == dtm.timestamp()361 rv.close()354 last_modified = datetime.datetime(1999, 1, 1)355356 @app.route('/')357 def index():358 return flask.send_file(StringIO("party like it's"), last_modified=last_modified)359360 c = app.test_client()361 rv = c.get('/')362 assert rv.last_modified == last_modified363364 def test_send_file_object(self):365 app = flask.Flask(__name__)366367 with app.test_request_context():
411 unmodified lines