v1.0.138: single httpx client for all chunks
This commit is contained in:
@@ -310,15 +310,15 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self._send_error_cors(400, "no file in request")
|
||||
return
|
||||
|
||||
# Режем на чанки по 12KB (hex = 24KB, влезает в лимит Lucee ~50KB)
|
||||
# Режем на чанки и шлём через один клиент
|
||||
CHUNK = 12000
|
||||
upload_id = str(uuid.uuid4())
|
||||
raw = file_data
|
||||
total = (len(raw) + CHUNK - 1) // CHUNK
|
||||
|
||||
with httpx.Client(http2=True, timeout=30) as client:
|
||||
for i in range(total):
|
||||
chunk = raw[i*CHUNK:(i+1)*CHUNK]
|
||||
with httpx.Client(http2=True, timeout=30) as client:
|
||||
r = client.post(
|
||||
f"{LUCEE_URL}/chunk.cfm?action=put",
|
||||
json={
|
||||
@@ -333,11 +333,11 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self._send_error_cors(502, f"chunk {i+1}/{total} failed: HTTP {r.status_code}")
|
||||
return
|
||||
|
||||
# Собрать чанки в Lucee
|
||||
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},
|
||||
timeout=60
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
self.send_response(200)
|
||||
|
||||
Reference in New Issue
Block a user