From 0867a6ef40150bf55c4bcb100fa98ab52506ceac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Fri, 10 Sep 2021 17:58:48 +0300 Subject: [PATCH] Use itemtypes to figure out the mime type in HTTP mode --- neomi.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/neomi.py b/neomi.py index c0b5d2c..7d4e23c 100644 --- a/neomi.py +++ b/neomi.py @@ -411,6 +411,7 @@ def read_infofile(file_path): # TODO: Read from file extension_mimetypes = {'.txt': 'text/plain', '.text': 'text/plain', '.log': 'text/plain', '.html': 'text/html'} +itemtype_mimetypes = {'0': 'text/plain', '1': 'text/x-gophermap', 'h': 'text/html'} mimetype_cache = {} mimetype_cache_lock = threading.Lock() @@ -726,7 +727,10 @@ class Serve(threading.Thread): try: full_path = get_full_path(path, config = self.config) - mimetype = get_mimetype(full_path, config = self.config) + if protocol == Protocol.http and itemtype in itemtype_mimetypes: + mimetype = itemtype_mimetypes[itemtype] + else: + mimetype = get_mimetype(full_path, config = self.config) file = get_file(full_path, config = self.config) except FileNotFoundError: