response = self.fetch(path % int(include_host))
self.assertEqual(response.body, utf8(str(True)))
- def test_static_304(self):
+ def test_static_304_if_modified_since(self):
response1 = self.fetch("/static/robots.txt")
response2 = self.fetch("/static/robots.txt", headers={
'If-Modified-Since': response1.headers['Last-Modified']})
self.assertEqual(response2.code, 304)
self.assertTrue('Content-Length' not in response2.headers)
self.assertTrue('Last-Modified' not in response2.headers)
+
+ def test_static_304_if_none_match(self):
+ response1 = self.fetch("/static/robots.txt")
+ response2 = self.fetch("/static/robots.txt", headers={
+ 'If-None-Match': response1.headers['Etag']})
+ self.assertEqual(response2.code, 304)
wsgi_safe.append(StaticFileTest)
class CustomStaticFileTest(WebTestCase):
self.set_header("Expires", datetime.datetime.utcnow() +
datetime.timedelta(seconds=cache_time))
self.set_header("Cache-Control", "max-age=" + str(cache_time))
- else:
- self.set_header("Cache-Control", "public")
self.set_extra_headers(path)
with open(abspath, "rb") as file:
data = file.read()
- hasher = hashlib.sha1()
- hasher.update(data)
- self.set_header("Etag", '"%s"' % hasher.hexdigest())
if include_body:
self.write(data)
else:
``get_auth_http_client``, which can be overridden to use a non-default
`AsyncHTTPClient` instance (e.g. to use a different `IOLoop`)
* `tornado.auth.TwitterMixin` now works on Python 3.
+* ``Etag``/``If-None-Match`` requests now work with `StaticFileHandler`.
+* `StaticFileHandler` no longer sets ``Cache-Control: public`` unnecessarily.