about summary refs log tree commit diff
path: root/main.py
diff options
context:
space:
mode:
authorUltraQbik <no1skill@yandex.ru>2024-08-22 22:40:25 +0300
committerUltraQbik <no1skill@yandex.ru>2024-08-22 22:40:25 +0300
commitd3804d5ffb2c24c1e3ebb323621f9d15d01b8f65 (patch)
tree5ea4ffb08544b67a22099c4d7797e2658104678f /main.py
parent422e9c74b070ee82d225c0ef17193b295907e0b5 (diff)
downloadhttpy-d3804d5ffb2c24c1e3ebb323621f9d15d01b8f65.tar.gz
httpy-d3804d5ffb2c24c1e3ebb323621f9d15d01b8f65.zip
Add Content-Length header
Diffstat (limited to 'main.py')
-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():