Skip to content

Commit 95ff2d5

Browse files
committed
application/javascript is now text/javascript
ubuntu-22.04 chnged js file mime type from the depricated application/javascript. to text/javascript. client.py cache text/javascript like application/javascript test_liveserver: use current environment's mapping for .js files to mimetype.
1 parent f2a3fd6 commit 95ff2d5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

roundup/cgi/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ class Client:
342342
# Key can be mime type - all files of that mimetype will get the value
343343
Cache_Control = {
344344
'application/javascript': "public, max-age=1209600", # 2 weeks
345+
'text/javascript': "public, max-age=1209600", # 2 weeks
345346
'text/css': "public, max-age=4838400", # 8 weeks/2 months
346347
}
347348

test/test_liveserver.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import shutil, errno, pytest, json, gzip, os, re
1+
import shutil, errno, pytest, json, gzip, mimetypes, os, re
22

33
from roundup import i18n
44
from roundup import password
@@ -48,7 +48,9 @@ class WsgiSetup(LiveServerTestCase):
4848

4949
dirname = '_test_instance'
5050
backend = 'anydbm'
51-
51+
52+
js_mime_type = mimetypes.guess_type("utils.js")[0]
53+
5254
@classmethod
5355
def setup_class(cls):
5456
'''All tests in this class use the same roundup instance.
@@ -527,7 +529,7 @@ def test_ims(self):
527529
print(f.headers)
528530

529531
self.assertEqual(f.status_code, 200)
530-
expected = { 'Content-Type': 'application/javascript',
532+
expected = { 'Content-Type': self.js_mime_type,
531533
'Content-Encoding': 'gzip',
532534
'Vary': 'Accept-Encoding',
533535
}
@@ -586,7 +588,7 @@ def test_compression_gzipfile(self):
586588
print(f.headers)
587589

588590
self.assertEqual(f.status_code, 200)
589-
expected = { 'Content-Type': 'application/javascript',
591+
expected = { 'Content-Type': self.js_mime_type,
590592
'Content-Encoding': 'gzip',
591593
'Vary': 'Accept-Encoding',
592594
'Content-Length': '69',
@@ -612,7 +614,7 @@ def test_compression_gzipfile(self):
612614
print(f.headers)
613615
614616
self.assertEqual(f.status_code, 200)
615-
expected = { 'Content-Type': 'application/javascript',
617+
expected = { 'Content-Type': self.js_mime_type,
616618
'Content-Encoding': 'br',
617619
'Vary': 'Accept-Encoding',
618620
'Content-Length': '960',
@@ -646,7 +648,7 @@ def test_compression_gzipfile(self):
646648
print(f.headers)
647649

648650
self.assertEqual(f.status_code, 200)
649-
expected = { 'Content-Type': 'application/javascript',
651+
expected = { 'Content-Type': self.js_mime_type,
650652
'Content-Encoding': 'gzip',
651653
'Vary': 'Accept-Encoding',
652654
}
@@ -824,7 +826,7 @@ def test_compression_gzip(self, method='gzip'):
824826
print(f.headers)
825827

826828
self.assertEqual(f.status_code, 200)
827-
expected = { 'Content-Type': 'application/javascript',
829+
expected = { 'Content-Type': self.js_mime_type,
828830
'Content-Encoding': method,
829831
'Vary': 'Accept-Encoding',
830832
}

0 commit comments

Comments
 (0)