Merge remote-tracking branch 'upstream/0.12-maintenance'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Adrian Moennich · committed by Adrian Moennich · parents 2ef2000, c52e1b7 · Browse files · 3 files·+32 added−2 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+32 added−2 removed
- tests:+22 added−1 removed
- other:+10 added−1 removed
Provenance
- Commit
eb1c2fa- Tree
19a2c04- Author
Adrian Moennich <adrian@planetcoding.net>- Committer
Adrian Moennich <adrian@planetcoding.net>- Parent 1
2ef2000- Parent 2
c52e1b7
3 files changed+32 added−2 removed
modified:flask/helpers.py+2 added-1 removed
608 unmodified lines609 try:610 rv = rv.make_conditional(request, accept_ranges=True,611 complete_length=fsize)612 except RequestedRangeNotSatisfiable:613+ if file is not None:613- file.close()614+ file.close()615 raise616 else:617 rv = rv.make_conditional(request)618 # make sure we don't send x-sendfile for servers that402 unmodified linesmodified:tests/test_helpers.py+22 added-1 removed
504 unmodified lines505 rv.close()506 507 @pytest.mark.skipif(508 not callable(getattr(Range, 'to_content_range_header', None)),509- reason="not implement within werkzeug"509+ reason="not implemented within werkzeug"510 )511 def test_send_file_range_request(self, app, client):512 @app.route('/')513 def index():48 unmodified lines562 datetime.datetime(1999, 1, 1))})563 assert rv.status_code == 200564 rv.close()565 566+ @pytest.mark.skipif(567+ not callable(getattr(Range, 'to_content_range_header', None)),568+ reason="not implemented within werkzeug"569+ )570+ def test_send_file_range_request_xsendfile_invalid(self, app, client):571+ # https://github.com/pallets/flask/issues/2526572+ app.use_x_sendfile = True573+574+ rv = client.get('/', headers={'Range': 'bytes=1000-'})575+ assert rv.status_code == 416576+ rv.close()577+578 def test_attachment(self, app, req_ctx):579+ app = flask.Flask(__name__)580+ with app.test_request_context():581+ with open(os.path.join(app.root_path, 'static/index.html')) as f:582+ rv = flask.send_file(f, as_attachment=True,583+ attachment_filename='index.html')584+ value, options = \585+ parse_options_header(rv.headers['Content-Disposition'])586+ assert value == 'attachment'587+ rv.close()588 589 with open(os.path.join(app.root_path, 'static/index.html')) as f:590 rv = flask.send_file(f, as_attachment=True,591 attachment_filename='index.html')318 unmodified linesmodified:CHANGES+8 added
146 unmodified lines147 .. _#2430: https://github.com/pallets/flask/pull/2430148 .. _#2436: https://github.com/pallets/flask/pull/2436149 .. _#2450: https://github.com/pallets/flask/pull/2450150 151+Version 0.12.3152+--------------153+154+Bugfix release, unreleased155+156+- Fix a ValueError caused by invalid Range requests in some cases157+158+159 Version 0.12.2160 --------------161 162 Released on May 16 2017616 unmodified lines