|
|
@ -349,7 +349,7 @@ class TestSendfile(object): |
|
|
|
assert rv.mimetype == 'text/html' |
|
|
|
assert rv.mimetype == 'text/html' |
|
|
|
rv.close() |
|
|
|
rv.close() |
|
|
|
|
|
|
|
|
|
|
|
def test_send_file_object(self, recwarn): |
|
|
|
def test_send_file_object(self): |
|
|
|
app = flask.Flask(__name__) |
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
|
|
|
|
|
|
|
with app.test_request_context(): |
|
|
|
with app.test_request_context(): |
|
|
@ -361,10 +361,6 @@ class TestSendfile(object): |
|
|
|
assert rv.mimetype == 'text/html' |
|
|
|
assert rv.mimetype == 'text/html' |
|
|
|
rv.close() |
|
|
|
rv.close() |
|
|
|
|
|
|
|
|
|
|
|
# mimetypes + etag |
|
|
|
|
|
|
|
recwarn.pop(DeprecationWarning) |
|
|
|
|
|
|
|
recwarn.pop(DeprecationWarning) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.use_x_sendfile = True |
|
|
|
app.use_x_sendfile = True |
|
|
|
|
|
|
|
|
|
|
|
with app.test_request_context(): |
|
|
|
with app.test_request_context(): |
|
|
@ -376,10 +372,6 @@ class TestSendfile(object): |
|
|
|
os.path.join(app.root_path, 'static/index.html') |
|
|
|
os.path.join(app.root_path, 'static/index.html') |
|
|
|
rv.close() |
|
|
|
rv.close() |
|
|
|
|
|
|
|
|
|
|
|
# mimetypes + etag |
|
|
|
|
|
|
|
recwarn.pop(DeprecationWarning) |
|
|
|
|
|
|
|
recwarn.pop(DeprecationWarning) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.use_x_sendfile = False |
|
|
|
app.use_x_sendfile = False |
|
|
|
with app.test_request_context(): |
|
|
|
with app.test_request_context(): |
|
|
|
f = StringIO('Test') |
|
|
|
f = StringIO('Test') |
|
|
@ -389,9 +381,6 @@ class TestSendfile(object): |
|
|
|
assert rv.mimetype == 'application/octet-stream' |
|
|
|
assert rv.mimetype == 'application/octet-stream' |
|
|
|
rv.close() |
|
|
|
rv.close() |
|
|
|
|
|
|
|
|
|
|
|
# etags |
|
|
|
|
|
|
|
recwarn.pop(DeprecationWarning) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PyStringIO(object): |
|
|
|
class PyStringIO(object): |
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
self._io = StringIO(*args, **kwargs) |
|
|
|
self._io = StringIO(*args, **kwargs) |
|
|
@ -405,11 +394,6 @@ class TestSendfile(object): |
|
|
|
assert rv.mimetype == 'text/plain' |
|
|
|
assert rv.mimetype == 'text/plain' |
|
|
|
rv.close() |
|
|
|
rv.close() |
|
|
|
|
|
|
|
|
|
|
|
# attachment_filename and etags |
|
|
|
|
|
|
|
a = recwarn.pop(DeprecationWarning) |
|
|
|
|
|
|
|
b = recwarn.pop(DeprecationWarning) |
|
|
|
|
|
|
|
c = recwarn.pop(UserWarning) # file not found |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f = StringIO('Test') |
|
|
|
f = StringIO('Test') |
|
|
|
rv = flask.send_file(f, mimetype='text/plain') |
|
|
|
rv = flask.send_file(f, mimetype='text/plain') |
|
|
|
rv.direct_passthrough = False |
|
|
|
rv.direct_passthrough = False |
|
|
@ -417,9 +401,6 @@ class TestSendfile(object): |
|
|
|
assert rv.mimetype == 'text/plain' |
|
|
|
assert rv.mimetype == 'text/plain' |
|
|
|
rv.close() |
|
|
|
rv.close() |
|
|
|
|
|
|
|
|
|
|
|
# etags |
|
|
|
|
|
|
|
recwarn.pop(DeprecationWarning) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.use_x_sendfile = True |
|
|
|
app.use_x_sendfile = True |
|
|
|
|
|
|
|
|
|
|
|
with app.test_request_context(): |
|
|
|
with app.test_request_context(): |
|
|
@ -428,10 +409,7 @@ class TestSendfile(object): |
|
|
|
assert 'x-sendfile' not in rv.headers |
|
|
|
assert 'x-sendfile' not in rv.headers |
|
|
|
rv.close() |
|
|
|
rv.close() |
|
|
|
|
|
|
|
|
|
|
|
# etags |
|
|
|
def test_attachment(self): |
|
|
|
recwarn.pop(DeprecationWarning) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_attachment(self, recwarn): |
|
|
|
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
app = flask.Flask(__name__) |
|
|
|
with app.test_request_context(): |
|
|
|
with app.test_request_context(): |
|
|
|
with open(os.path.join(app.root_path, 'static/index.html')) as f: |
|
|
|
with open(os.path.join(app.root_path, 'static/index.html')) as f: |
|
|
@ -441,10 +419,6 @@ class TestSendfile(object): |
|
|
|
assert value == 'attachment' |
|
|
|
assert value == 'attachment' |
|
|
|
rv.close() |
|
|
|
rv.close() |
|
|
|
|
|
|
|
|
|
|
|
# mimetypes + etag |
|
|
|
|
|
|
|
assert len(recwarn.list) == 2 |
|
|
|
|
|
|
|
recwarn.clear() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with app.test_request_context(): |
|
|
|
with app.test_request_context(): |
|
|
|
assert options['filename'] == 'index.html' |
|
|
|
assert options['filename'] == 'index.html' |
|
|
|
rv = flask.send_file('static/index.html', as_attachment=True) |
|
|
|
rv = flask.send_file('static/index.html', as_attachment=True) |
|
|
|