MCPcopy Create free account
hub / github.com/SuperJJ007/CSSwitch / _send_json

Method _send_json

proxy/csswitch_proxy.py:735–744  ·  view source on GitHub ↗
(self, code, obj)

Source from the content-addressed store, hash-verified

733 pass
734
735 def _send_json(self, code, obj):
736 body = json.dumps(obj, ensure_ascii=False).encode()
737 self.send_response(code)
738 self.send_header("Content-Type", "application/json")
739 self.send_header("Content-Length", str(len(body)))
740 if self.close_connection:
741 # 主动关闭连接时显式告知客户端,避免其在已关闭的 socket 上复用连接。
742 self.send_header("Connection", "close")
743 self.end_headers()
744 self.wfile.write(body)
745
746 def _sse(self, event, data):
747 chunk = f"event: {event}\ndata: {json.dumps(data, ensure_ascii=False)}\n\n".encode()

Callers 5

_auth_okMethod · 0.95
do_GETMethod · 0.95
do_POSTMethod · 0.95
_handle_anthropicMethod · 0.95
_handle_openaiMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected