v1.0.137: fix chunk upload — use httpx.Client(http2=True) for ddos-guard
This commit is contained in:
@@ -318,7 +318,8 @@ 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:
|
||||||
|
r = client.post(
|
||||||
f"{LUCEE_URL}/chunk.cfm?action=put",
|
f"{LUCEE_URL}/chunk.cfm?action=put",
|
||||||
json={
|
json={
|
||||||
"upload_id": upload_id,
|
"upload_id": upload_id,
|
||||||
@@ -327,17 +328,16 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
"filename": filename,
|
"filename": filename,
|
||||||
"data": chunk.hex(),
|
"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:
|
||||||
|
resp = client.post(
|
||||||
f"{LUCEE_URL}/chunk.cfm?action=assemble",
|
f"{LUCEE_URL}/chunk.cfm?action=assemble",
|
||||||
json={"upload_id": upload_id, "contract_id": contract_id},
|
json={"upload_id": upload_id, "contract_id": contract_id},
|
||||||
timeout=60
|
|
||||||
)
|
)
|
||||||
if resp.status_code == 200:
|
if resp.status_code == 200:
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
|
|||||||
Reference in New Issue
Block a user