v1.0.137: fix chunk upload — use httpx.Client(http2=True) for ddos-guard

This commit is contained in:
2026-06-23 09:11:34 +04:00
parent efc270bdf3
commit f04f698bd8
+16 -16
View File
@@ -318,27 +318,27 @@ class Handler(BaseHTTPRequestHandler):
for i in range(total): for i in range(total):
chunk = raw[i*CHUNK:(i+1)*CHUNK] chunk = raw[i*CHUNK:(i+1)*CHUNK]
r = httpx.post( with httpx.Client(http2=True, timeout=30) as client:
f"{LUCEE_URL}/chunk.cfm?action=put", r = client.post(
json={ f"{LUCEE_URL}/chunk.cfm?action=put",
"upload_id": upload_id, json={
"chunk_index": i, "upload_id": upload_id,
"total_chunks": total, "chunk_index": i,
"filename": filename, "total_chunks": total,
"data": chunk.hex(), "filename": filename,
}, "data": chunk.hex(),
timeout=30 },
) )
if r.status_code != 200: if r.status_code != 200:
self._send_error_cors(502, f"chunk {i+1}/{total} failed: HTTP {r.status_code}") self._send_error_cors(502, f"chunk {i+1}/{total} failed: HTTP {r.status_code}")
return return
# Собрать чанки в Lucee # Собрать чанки в Lucee
resp = httpx.post( with httpx.Client(http2=True, timeout=60) as client:
f"{LUCEE_URL}/chunk.cfm?action=assemble", resp = client.post(
json={"upload_id": upload_id, "contract_id": contract_id}, f"{LUCEE_URL}/chunk.cfm?action=assemble",
timeout=60 json={"upload_id": upload_id, "contract_id": contract_id},
) )
if resp.status_code == 200: if resp.status_code == 200:
self.send_response(200) self.send_response(200)
self._send_cors() self._send_cors()