Browse Source

need to test against raw header

parsing prefers the last value parsed for the option
pull/2223/head
David Lord 8 years ago
parent
commit
f790ab7177
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
  1. 21
      tests/test_helpers.py

21
tests/test_helpers.py

@ -541,7 +541,7 @@ class TestSendfile(object):
parse_options_header(rv.headers['Content-Disposition']) parse_options_header(rv.headers['Content-Disposition'])
assert value == 'attachment' assert value == 'attachment'
assert options['filename'] == 'index.html' assert options['filename'] == 'index.html'
assert 'filename*' not in options assert 'filename*' not in rv.headers['Content-Disposition']
rv.close() rv.close()
with app.test_request_context(): with app.test_request_context():
@ -565,20 +565,15 @@ class TestSendfile(object):
app = flask.Flask(__name__) app = flask.Flask(__name__)
with app.test_request_context(): with app.test_request_context():
rv = flask.send_file( rv = flask.send_file('static/index.html', as_attachment=True, attachment_filename=u'Ñandú/pingüino.txt')
'static/index.html', as_attachment=True, content_disposition = set(rv.headers['Content-Disposition'].split('; '))
attachment_filename=u'Ñandú/pingüino.txt' assert content_disposition == set((
) 'attachment',
value, options = parse_options_header( 'filename="Nandu/pinguino.txt"',
rv.headers['Content-Disposition'] "filename*=UTF-8''%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt"
) ))
rv.close() rv.close()
assert value == 'attachment'
assert sorted(options.keys()) == ('filename', 'filename*')
assert options['filename'] == 'Nandu/pinguino.txt'
assert options['filename*'] == 'UTF-8''%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt'
def test_static_file(self): def test_static_file(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
# default cache timeout is 12 hours # default cache timeout is 12 hours

Loading…
Cancel
Save