From d5664f33e1737c1f30643de97636980d6805c2c9 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Tue, 21 Jun 2022 03:30:07 +0200 Subject: [PATCH] Ditto --- modules/http/file-handlers/text.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/http/file-handlers/text.py b/modules/http/file-handlers/text.py index a183f81..bb4195a 100644 --- a/modules/http/file-handlers/text.py +++ b/modules/http/file-handlers/text.py @@ -1,7 +1,8 @@ global handleText def handleText(env): + filePath = env["fPath"] data = b"" - lastModified = 0 + lastModified = None with fileLock: with open(env["fPath"],"rb") as textFile: data = textFile.read() @@ -9,16 +10,18 @@ def handleText(env): lastModified = os.path.getmtime(filePath) except: pass - lastModified = email.utils.formatdate(lastModified).replace("-0000","GMT") + + headers = { + "Content-Type": mimetypesText[env["fileExt"]]+ "; charset=UTF-8", + "Accept-Ranges": "none", + "Date": env["requestTimeFormatted"] + } + + if lastModified != None: + headers["Last-Modified"] = email.utils.formatdate(lastModified).replace("-0000","GMT") simpleResponse( - env["self"].connection,"200 OK", - { - "Content-Type": mimetypesText[env["fileExt"]]+ "; charset=UTF-8", - "Accept-Ranges": "none", - "Date": env["requestTimeFormatted"], - "Last-Modified": lastModified - },data + env["self"].connection,"200 OK",headers,data ) for t in mimetypesText: