forked from orbit-oss/flask
Add last_modified arg for send_file
Enhancement: Add last_modified arg of type DateTime to send_file. Fixes pallets/flask#1321
This commit is contained in:
parent
64a37bb9b7
commit
af515cc7ea
2 changed files with 22 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ from logging import StreamHandler
|
|||
from werkzeug.exceptions import BadRequest, NotFound
|
||||
from werkzeug.http import parse_cache_control_header, parse_options_header
|
||||
from werkzeug.http import http_date
|
||||
from flask._compat import StringIO, text_type
|
||||
from flask._compat import StringIO, text_type, PY2
|
||||
|
||||
|
||||
def has_encoding(name):
|
||||
|
|
@ -349,6 +349,17 @@ class TestSendfile(object):
|
|||
assert rv.mimetype == 'text/html'
|
||||
rv.close()
|
||||
|
||||
def test_send_file_last_modified(self):
|
||||
app = flask.Flask(__name__)
|
||||
with app.test_request_context():
|
||||
dtm = datetime.datetime.now()
|
||||
rv = flask.send_file('static/index.html', last_modified=dtm)
|
||||
if PY2:
|
||||
assert rv.last_modified == int(dtm.strftime("%s"))
|
||||
else:
|
||||
assert rv.last_modified == dtm.timestamp()
|
||||
rv.close()
|
||||
|
||||
def test_send_file_object(self):
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue