about summary refs log tree commit diff
path: root/main.py
diff options
context:
space:
mode:
authorUltraQbik <no1skill@yandex.ru>2024-08-24 22:58:13 +0300
committerUltraQbik <no1skill@yandex.ru>2024-08-24 22:58:13 +0300
commit2998b5a95526f268e3b6dd7039a8a82258553924 (patch)
tree3b87a625c982957c88d9cd4999297de7fffa78ff /main.py
parent7a5b91166114b323cdea0de8148d6b67be3cce7b (diff)
downloadhttpy-2998b5a95526f268e3b6dd7039a8a82258553924.tar.gz
httpy-2998b5a95526f268e3b6dd7039a8a82258553924.zip
Don't compress what is already compressed
Diffstat (limited to 'main.py')
-rw-r--r--main.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/main.py b/main.py
index 75f9064..8760d15 100644
--- a/main.py
+++ b/main.py
@@ -208,12 +208,17 @@ class HTTPServer:
                 data = minimize_html(data)
 
             if request.type == "GET":
-                return Response(data, STATUS_CODE_OK)
+                response = Response(data, STATUS_CODE_OK)
             elif request.type == "HEAD":
-                return Response(b'', STATUS_CODE_OK, {"Content-Length": len(data)})
+                response = Response(b'', STATUS_CODE_OK, {"Content-Length": len(data)})
             else:
                 raise TypeError("Called GET handler for non-GET request")
 
+            if filepath[-4:] == "webp":
+                response.compress = False
+
+            return response
+
         elif len(split_path) >= 2 and split_path[0] in API_VERSIONS:  # assume script
             # unsupported API version
             if not API_VERSIONS[split_path[0]]: