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: