mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 15:57:14 +03:00
add deflate support
This commit is contained in:
parent
45dba2ba88
commit
10824250e1
@ -4,6 +4,7 @@ import json
|
||||
import pathlib
|
||||
import tempfile
|
||||
import threading
|
||||
import zlib
|
||||
from http import server
|
||||
from typing import Any, Callable, Tuple, Union
|
||||
from urllib.parse import parse_qs
|
||||
@ -34,6 +35,16 @@ class LoggingHandler(server.BaseHTTPRequestHandler):
|
||||
data_raw: bytes = self.rfile.read(int(self.headers['Content-Length']))
|
||||
data: str | bytes
|
||||
|
||||
match self.headers.get('Content-Encoding'):
|
||||
case 'gzip':
|
||||
data = gzip.decompress(data_raw).decode('utf-8', errors='replace')
|
||||
|
||||
case 'deflate':
|
||||
zlib.decompress(data_raw).decode('utf-8', errors='replace')
|
||||
|
||||
case _:
|
||||
data = data_raw.decode('utf-8', errors='replace')
|
||||
|
||||
if self.headers.get('Content-Encoding') == 'gzip':
|
||||
data = gzip.decompress(data_raw).decode('utf-8', errors='replace')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user