From f04f698bd8d33e4ed0d25342fe4a580f920c4858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Tue, 23 Jun 2026 09:11:34 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.137:=20fix=20chunk=20upload=20=E2=80=94=20?= =?UTF-8?q?use=20httpx.Client(http2=3DTrue)=20for=20ddos-guard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/convert_server.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/deploy/convert_server.py b/deploy/convert_server.py index 9b73019..d4ffe1a 100755 --- a/deploy/convert_server.py +++ b/deploy/convert_server.py @@ -318,27 +318,27 @@ class Handler(BaseHTTPRequestHandler): for i in range(total): chunk = raw[i*CHUNK:(i+1)*CHUNK] - r = httpx.post( - f"{LUCEE_URL}/chunk.cfm?action=put", - json={ - "upload_id": upload_id, - "chunk_index": i, - "total_chunks": total, - "filename": filename, - "data": chunk.hex(), - }, - timeout=30 - ) + with httpx.Client(http2=True, timeout=30) as client: + r = client.post( + f"{LUCEE_URL}/chunk.cfm?action=put", + json={ + "upload_id": upload_id, + "chunk_index": i, + "total_chunks": total, + "filename": filename, + "data": chunk.hex(), + }, + ) if r.status_code != 200: self._send_error_cors(502, f"chunk {i+1}/{total} failed: HTTP {r.status_code}") return # Собрать чанки в Lucee - resp = httpx.post( - f"{LUCEE_URL}/chunk.cfm?action=assemble", - json={"upload_id": upload_id, "contract_id": contract_id}, - timeout=60 - ) + with httpx.Client(http2=True, timeout=60) as client: + resp = client.post( + f"{LUCEE_URL}/chunk.cfm?action=assemble", + json={"upload_id": upload_id, "contract_id": contract_id}, + ) if resp.status_code == 200: self.send_response(200) self._send_cors()