diff options
| author | UltraQbik <no1skill@yandex.ru> | 2024-08-24 22:58:13 +0300 |
|---|---|---|
| committer | UltraQbik <no1skill@yandex.ru> | 2024-08-24 22:58:13 +0300 |
| commit | 2998b5a95526f268e3b6dd7039a8a82258553924 (patch) | |
| tree | 3b87a625c982957c88d9cd4999297de7fffa78ff /main.py | |
| parent | 7a5b91166114b323cdea0de8148d6b67be3cce7b (diff) | |
| download | httpy-2998b5a95526f268e3b6dd7039a8a82258553924.tar.gz httpy-2998b5a95526f268e3b6dd7039a8a82258553924.zip | |
Don't compress what is already compressed
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 9 |
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]]: |