From 3f4bdfef113bfe7ce7627a1ed5a39aaf0f5f9d65 Mon Sep 17 00:00:00 2001 From: ziajka Date: Fri, 22 Mar 2019 08:35:27 +0100 Subject: [PATCH] Fix mimetype for javascript, #1559 --- gns3server/handlers/index_handler.py | 8 +++++++- gns3server/web/response.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gns3server/handlers/index_handler.py b/gns3server/handlers/index_handler.py index 74eead8e..364bf902 100644 --- a/gns3server/handlers/index_handler.py +++ b/gns3server/handlers/index_handler.py @@ -92,7 +92,13 @@ class IndexHandler: if static is None or not os.path.exists(static): static = get_resource(os.path.join('static', 'web-ui', 'index.html')) - await response.stream_file(static) + # guesstype prefers to have text/html type than application/javascript + # which results with warnings in Firefox 66 on Windows + # Ref. gns3-server#1559 + _, ext = os.path.splitext(static) + mimetype = ext == '.js' and 'application/javascript' or None + + await response.stream_file(static, status=200, set_content_type=mimetype) @Route.get( r"/v1/version", diff --git a/gns3server/web/response.py b/gns3server/web/response.py index 6405dd4e..0a51490a 100644 --- a/gns3server/web/response.py +++ b/gns3server/web/response.py @@ -118,6 +118,7 @@ class Response(aiohttp.web.Response): """ Stream a file as a response """ + encoding = None if not os.path.exists(path): raise aiohttp.web.HTTPNotFound()