diff --git a/src/ProxyImp.cpp b/src/ProxyImp.cpp index e6b6ea8..84583b0 100755 --- a/src/ProxyImp.cpp +++ b/src/ProxyImp.cpp @@ -154,35 +154,33 @@ int ProxyImp::doRequest(tars::TarsCurrentPtr current, vector &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) {