add jaxxks mutex lock for proxy during request

This commit is contained in:
Concedo 2026-03-31 17:03:38 +08:00
parent 2acf209972
commit 088c01e2a7

View file

@ -3983,26 +3983,27 @@ class KcppProxyHandler(http.server.BaseHTTPRequestHandler):
self.wfile.write(html_502.encode("utf-8"))
return
self.send_response(resp.status, resp.reason) # forward response headers
for k, v in resp.getheaders():
lk = k.lower()
if lk in self.HOP_BY_HOP:
continue
self.send_header(k, v)
self.end_headers()
self.close_connection = True
with proxy_reload_lock:
self.send_response(resp.status, resp.reason) # forward response headers
for k, v in resp.getheaders():
lk = k.lower()
if lk in self.HOP_BY_HOP:
continue
self.send_header(k, v)
self.end_headers()
self.close_connection = True
try: # stream response
while True:
chunk = resp.read(self.STREAM_CHUNK)
if not chunk:
break
self.wfile.write(chunk)
self.wfile.flush()
except (BrokenPipeError, ConnectionResetError):
pass
finally:
conn.close()
try: # stream response
while True:
chunk = resp.read(self.STREAM_CHUNK)
if not chunk:
break
self.wfile.write(chunk)
self.wfile.flush()
except (BrokenPipeError, ConnectionResetError):
pass
finally:
conn.close()
# proxy all HTTP methods
do_GET = _handle