Skip to content

Commit

Permalink
Merge pull request #26 from lvxy1024/master
Browse files Browse the repository at this point in the history
修改使用tars-tup/tars-json协议压缩加密方式访问Gateway直接返回500
  • Loading branch information
shevqko authored Jul 18, 2023
2 parents a2351ee + a6f9a4b commit 4d7ef41
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/ProxyImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,35 +154,33 @@ int ProxyImp::doRequest(tars::TarsCurrentPtr current, vector<char> &response)
{
stParam->sEncryptKey = _sEncryptKey;
}
else

// 设置应答时使用的压缩及加密头
setRspEncodingToHeader(stParam->httpRequest, stParam->pairAcceptZip, stParam->pairAcceptEpt);

/// 从HTTP POST Data或者GET参数中取出Tup数据
if (getDataFromHTTPRequest(stParam->httpRequest, stParam->buffer) != 0)
{
TLOG_ERROR("getDataFromHTTPRequest failed"
<< ",sGUID:" << stParam->sGUID << endl);
current->setResponse(false);
ProxyUtils::doErrorRsp(400, current, stParam->proxyType, stParam->httpKeepAlive, "getDataFromHTTPRequest failed");
return 0;
}

/// 解压,解密数据
if (getRealDataByDecode(stParam) != 0)
{
// 设置应答时使用的压缩及加密头
setRspEncodingToHeader(stParam->httpRequest, stParam->pairAcceptZip, stParam->pairAcceptEpt);

/// 从HTTP POST Data或者GET参数中取出Tup数据
if (getDataFromHTTPRequest(stParam->httpRequest, stParam->buffer) != 0)
{
TLOG_ERROR("getDataFromHTTPRequest failed"
<< ",sGUID:" << stParam->sGUID << endl);
current->setResponse(false);
ProxyUtils::doErrorRsp(400, current, stParam->proxyType, stParam->httpKeepAlive, "getDataFromHTTPRequest failed");
return 0;
}

/// 解压,解密数据
if (getRealDataByDecode(stParam) != 0)
{
TLOG_ERROR("getRealDataByDecode failed"
<< ",sGUID:" << stParam->sGUID << endl);
ProxyUtils::doErrorRsp(400, stParam->current, stParam->proxyType, stParam->httpKeepAlive, "getRealDataByDecode failed");
return 0;
}
TLOG_ERROR("getRealDataByDecode failed"
<< ",sGUID:" << stParam->sGUID << endl);
ProxyUtils::doErrorRsp(400, stParam->current, stParam->proxyType, stParam->httpKeepAlive, "getRealDataByDecode failed");
return 0;
}

// stParam->buffer = &sTupData[0];
// stParam->length = sTupData.size();

return handleTarsRequest(stParam);
}
return handleTarsRequest(stParam);
}
catch (exception &ex)
{
Expand Down

0 comments on commit 4d7ef41

Please sign in to comment.