v1.0.137: fix chunk upload — use httpx.Client(http2=True) for ddos-guard
This commit is contained in:
+16
-16
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user