about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--main.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/main.py b/main.py
index dc9f97d..5101159 100644
--- a/main.py
+++ b/main.py
@@ -277,6 +277,10 @@ class HTTPServer:
         elif headers.get("Content-Encoding") == "gzip":
             data = gzip.compress(data)
 
+        # add 'Content-Length' header if not present
+        if headers.get("Content-Length") is None:
+            headers["Content-Length"] = len(data)
+
         # format headers
         byte_header = bytearray()
         for key, value in headers.items():