From b4a74c4bd913b1769ed1b44c71e5b6949b6bb5e4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 5 Apr 2024 16:32:45 +0800 Subject: [PATCH] 1 --- server/wsproxy/mastermgr.cc | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/server/wsproxy/mastermgr.cc b/server/wsproxy/mastermgr.cc index fd5602c..af48b5a 100644 --- a/server/wsproxy/mastermgr.cc +++ b/server/wsproxy/mastermgr.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include "mastermgr.h" #include "master.h" @@ -107,17 +108,11 @@ void MasterMgr::_SS_MS_ResponseTargetServer(f8::MsgHdr* hdr, const ss::SS_MS_Res void MasterMgr::_SS_MS_HttpTunnelResponse(f8::MsgHdr* hdr, const ss::SS_MS_HttpTunnelResponse& msg) { +#ifdef DEBUG + a8::XPrintf("SS_MS_HttpTunnelResponse %s\n" , {f8::PbToJson(&msg)}); +#endif auto req = GetHttpTunnelRequestByContextId(msg.context_id()); if (req) { -#ifdef DEBUG - a8::XPrintf("httpTunnel error_code:%d error_msg:%s host:%s port:%d\n", - { - msg.error_code(), - msg.error_msg(), - msg.host(), - msg.port() - }); -#endif if (msg.error_code() == 0) { std::weak_ptr conn = UpStreamMgr::Instance()->RecreateUpStream ( @@ -125,12 +120,14 @@ void MasterMgr::_SS_MS_HttpTunnelResponse(f8::MsgHdr* hdr, const ss::SS_MS_HttpT msg.port() ); if (!conn.expired()) { - ss::SS_HttpTunnelRequest msg; - msg.set_context_id(msg.context_id()); - msg.set_socket_handle(msg.socket_handle()); - msg.set_url(msg.url()); - msg.set_query_str(msg.query_str()); - conn.lock()->SendMsg(req->socket_handle, msg); + ss::SS_HttpTunnelRequest upmsg; + upmsg.set_context_id(msg.context_id()); + upmsg.set_socket_handle(req->socket_handle); + upmsg.set_url(req->request->GetUrl()); + std::string query_str; + req->request->GetParams()->ToUrlEncodeStr(query_str); + upmsg.set_query_str(query_str); + conn.lock()->SendMsg(req->socket_handle, upmsg); return; } else { abort(); @@ -149,8 +146,14 @@ void MasterMgr::_SS_MS_HttpTunnelResponse(f8::MsgHdr* hdr, const ss::SS_MS_HttpT void MasterMgr::_SS_HttpTunnelResponse(f8::MsgHdr* hdr, const ss::SS_HttpTunnelResponse& msg) { +#ifdef DEBUG + a8::XPrintf("SS_HttpTunnelResponse %s\n" , {f8::PbToJson(&msg)}); +#endif auto req = GetHttpTunnelRequestByContextId(msg.context_id()); if (req) { +#ifdef DEBUG + a8::XPrintf("SS_HttpTunnelResponse2 %s\n" , {f8::PbToJson(&msg)}); +#endif req->request->GetResp()->ReadFromJsonString(msg.response()); req->request->Response(); if (!req->timer_wp.expired()) {