fix: serve WebP with a portable MIME type

This commit is contained in:
nyan404 committed 2026-11-17 16:34:10 +03:00
1 parent d182cd30fa
commit 30d012de80
5 files changed
+23 -1

No files matched your search

+8
View File
@@ -2,6 +2,7 @@
import http.client
import threading
import unittest
from unittest.mock import patch
from app.main import BelkiHTTPServer, Handler
@@ -44,6 +45,13 @@ class TrainerRoutesTests(unittest.TestCase):
self.assertIn(media_type, content_type)
self.assertGreater(len(content), 0)
def test_webp_mime_does_not_depend_on_system_mime_database(self):
with patch('app.main.mimetypes.guess_type', return_value=(None, None)):
status, content_type, content = self.get('/lu-trainer/assets/forest.webp')
self.assertEqual(status, 200)
self.assertEqual(content_type, 'image/webp')
self.assertTrue(content.startswith(b'RIFF'))
def test_missing_and_escaping_assets_are_not_served(self):
for path in ['/lu-trainer/missing.js', '/lu-trainer/%2e%2e/%2e%2e/project-info.txt']:
self.assertEqual(self.get(path)[0], 404)