mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-20 01:31:42 +02:00
add jaxxks mutex lock for proxy during request
This commit is contained in:
+20
-19
@@ -3983,26 +3983,27 @@ class KcppProxyHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
self.wfile.write(html_502.encode("utf-8"))
|
self.wfile.write(html_502.encode("utf-8"))
|
||||||
return
|
return
|
||||||
|
|
||||||
self.send_response(resp.status, resp.reason) # forward response headers
|
with proxy_reload_lock:
|
||||||
for k, v in resp.getheaders():
|
self.send_response(resp.status, resp.reason) # forward response headers
|
||||||
lk = k.lower()
|
for k, v in resp.getheaders():
|
||||||
if lk in self.HOP_BY_HOP:
|
lk = k.lower()
|
||||||
continue
|
if lk in self.HOP_BY_HOP:
|
||||||
self.send_header(k, v)
|
continue
|
||||||
self.end_headers()
|
self.send_header(k, v)
|
||||||
self.close_connection = True
|
self.end_headers()
|
||||||
|
self.close_connection = True
|
||||||
|
|
||||||
try: # stream response
|
try: # stream response
|
||||||
while True:
|
while True:
|
||||||
chunk = resp.read(self.STREAM_CHUNK)
|
chunk = resp.read(self.STREAM_CHUNK)
|
||||||
if not chunk:
|
if not chunk:
|
||||||
break
|
break
|
||||||
self.wfile.write(chunk)
|
self.wfile.write(chunk)
|
||||||
self.wfile.flush()
|
self.wfile.flush()
|
||||||
except (BrokenPipeError, ConnectionResetError):
|
except (BrokenPipeError, ConnectionResetError):
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
# proxy all HTTP methods
|
# proxy all HTTP methods
|
||||||
do_GET = _handle
|
do_GET = _handle
|
||||||
|
|||||||
Reference in New Issue
Block a user