From 1b52185ece269c76d181e34c6172007bc3f43d36 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sat, 2 Oct 2021 09:19:56 -0600 Subject: [PATCH 1/2] Server: actually return MIME type The original paths being provided had a tailing slash, and so everything was returning as "application/octet-stream" (at least on Windows) --- pelican/server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pelican/server.py b/pelican/server.py index 6ebce8760..2000cd34f 100644 --- a/pelican/server.py +++ b/pelican/server.py @@ -91,7 +91,9 @@ def get_path_that_exists(self, original_path): def guess_type(self, path): """Guess at the mime type for the specified file. """ - mimetype = server.SimpleHTTPRequestHandler.guess_type(self, path) + # strip trailing slash + path = path.rstrip().strip("/").strip(os.sep) + mimetype = super().guess_type(path) # If the default guess is too generic, try the python-magic library if mimetype == 'application/octet-stream' and magic_from_file: From ac451c300ec7ae654b0ae1997c4c35a05474947a Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sat, 2 Oct 2021 12:32:36 -0600 Subject: [PATCH 2/2] Only strip seperators from the end of a path Otherwise, we might strip the "root" / off Unix pathes --- pelican/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pelican/server.py b/pelican/server.py index 2000cd34f..25c55303b 100644 --- a/pelican/server.py +++ b/pelican/server.py @@ -92,7 +92,7 @@ def guess_type(self, path): """Guess at the mime type for the specified file. """ # strip trailing slash - path = path.rstrip().strip("/").strip(os.sep) + path = path.rstrip().rstrip("/").rstrip(os.sep) mimetype = super().guess_type(path) # If the default guess is too generic, try the python-magic library