From: Ali Ebrahim Date: Thu, 30 Jul 2015 20:12:56 +0000 (-0700) Subject: test Content-Type for static compressed files X-Git-Tag: v4.3.0b1~68^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a881d9cb568456c0023ec07e4626b1a3a30612c;p=thirdparty%2Ftornado.git test Content-Type for static compressed files --- diff --git a/MANIFEST.in b/MANIFEST.in index 353f222fa..30cdcd082 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,6 +8,9 @@ include tornado/test/gettext_translations/fr_FR/LC_MESSAGES/tornado_test.mo include tornado/test/gettext_translations/fr_FR/LC_MESSAGES/tornado_test.po include tornado/test/options_test.cfg include tornado/test/static/robots.txt +include tornado/test/static/sample.xml +include tornado/test/static/sample.xml.gz +include tornado/test/static/sample.xml.bz2 include tornado/test/static/dir/index.html include tornado/test/static_foo.txt include tornado/test/templates/utf8.html diff --git a/setup.py b/setup.py index 576317588..49e436ec3 100644 --- a/setup.py +++ b/setup.py @@ -146,6 +146,9 @@ setup( "gettext_translations/fr_FR/LC_MESSAGES/tornado_test.po", "options_test.cfg", "static/robots.txt", + "static/sample.xml", + "static/sample.xml.gz", + "static/sample.xml.bz2", "static/dir/index.html", "static_foo.txt", "templates/utf8.html", diff --git a/tornado/test/static/sample.xml b/tornado/test/static/sample.xml new file mode 100644 index 000000000..35ea0e29d --- /dev/null +++ b/tornado/test/static/sample.xml @@ -0,0 +1,23 @@ + + + + 1 + 2008 + 141100 + + + + + 4 + 2011 + 59900 + + + + 68 + 2011 + 13600 + + + + diff --git a/tornado/test/static/sample.xml.bz2 b/tornado/test/static/sample.xml.bz2 new file mode 100644 index 000000000..44dc66333 Binary files /dev/null and b/tornado/test/static/sample.xml.bz2 differ diff --git a/tornado/test/static/sample.xml.gz b/tornado/test/static/sample.xml.gz new file mode 100644 index 000000000..c0fd5e6fd Binary files /dev/null and b/tornado/test/static/sample.xml.gz differ diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 5d8a20718..85c7552c9 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -978,6 +978,19 @@ class StaticFileTest(WebTestCase): response = self.fetch('/static/robots.txt') self.assertTrue(b"Disallow: /" in response.body) + self.assertEqual(response.headers.get("Content-Type"), "text/plain") + + def test_static_compressed_files(self): + response = self.fetch("/static/sample.xml.gz") + self.assertEqual(response.headers.get("Content-Type"), + "application/gzip") + response = self.fetch("/static/sample.xml.bz2") + self.assertEqual(response.headers.get("Content-Type"), + "application/octet-stream") + # make sure the uncompressed file still has the correct type + response = self.fetch("/static/sample.xml") + self.assertTrue(response.headers.get("Content-Type") + in set(("text/xml", "application/xml"))) def test_static_url(self): response = self.fetch("/static_url/robots.txt")