-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
Closed
Labels
Description
from flask import Flask, send_file
app = Flask(__name__)
app.use_x_sendfile = True
@app.route('/')
def index():
return send_file('/etc/passwd', mimetype='text/plain', conditional=True)http get http://127.0.0.1:8009/ Range:bytes=10000- (the range needs to be invalid, so depending on the file sent the number needs to be higher) fails with this ValueError:
Traceback (most recent call last):
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/adrian/dev/indico/src/flasktest.py", line 10, in index
return send_file('/etc/passwd', mimetype='text/plain', conditional=True)
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/helpers.py", line 594, in send_file
file.close()
AttributeError: 'NoneType' object has no attribute 'close'Probably just a missing if file is not None check.