Skip to content
Myr

Fixed sending etags for file streams with a name. This fixes #930.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 46c24da · Browse files · 3 files+25 added−8 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+25 added−8 removed

  • other:+25 added−8 removed

3 files+25 added−8 removed

modified:flask/testsuite/helpers.py+11 added
263 unmodified lines
264 rv.close()265 # etags266 self.assert_equal(len(captured), 1)267 with catch_warnings() as captured:268 from StringIO import StringIO as PYStringIO269 f = PYStringIO('Test')270 f.name = 'test.txt'271 rv = flask.send_file(f)272 rv.direct_passthrough = False273 self.assert_equal(rv.data, b'Test')274 self.assert_equal(rv.mimetype, 'text/plain')275 rv.close()276 # attachment_filename and etags277 self.assert_equal(len(captured), 3)278 with catch_warnings() as captured:279 f = StringIO('Test')280 rv = flask.send_file(f, mimetype='text/plain')281 rv.direct_passthrough = False282 self.assert_equal(rv.data, b'Test')
322 unmodified lines
modified:flask/helpers.py+13 added-8 removed
536 unmodified lines
537 rv.cache_control.max_age = cache_timeout538 rv.expires = int(time() + cache_timeout)539540 if add_etags and filename is not None:541 try:541 rv.set_etag('flask-%s-%s-%s' % (542 os.path.getmtime(filename),543 os.path.getsize(filename),544 adler32(545 filename.encode('utf-8') if isinstance(filename, text_type)546 else filename547 ) & 0xffffffff548 ))542 rv.set_etag('flask-%s-%s-%s' % (543 os.path.getmtime(filename),544 os.path.getsize(filename),545 adler32(546 filename.encode('utf-8') if isinstance(filename, text_type)547 else filename548 ) & 0xffffffff549 ))550 except OSError:551 warn('Access %s failed, maybe it does not exist, so ignore etags in '552 'headers' % filename, stacklevel=2)553554 if conditional:555 rv = rv.make_conditional(request)556 # make sure we don't send x-sendfile for servers that557 # ignore the 304 status code for x-sendfile.
302 unmodified lines
modified:CHANGES+1 added
15 unmodified lines
16 context to be passed to teardown handlers.17- Fixed an issue with query parameters getting removed from requests in18 the test client when absolute URLs were requested.19- Made `@before_first_request` into a decorator as intended.20- Fixed an etags bug when sending a file without a name.2122Version 0.10.123--------------24
457 unmodified lines