diff --git a/api/include/mk_events_objects.h b/api/include/mk_events_objects.h index 168d9b35..487d5e0c 100644 --- a/api/include/mk_events_objects.h +++ b/api/include/mk_events_objects.h @@ -47,8 +47,6 @@ typedef void* mk_parser; API_EXPORT const char* API_CALL mk_parser_get_method(const mk_parser ctx); //Parser::Url(),获取HTTP的访问url(不包括?后面的参数) API_EXPORT const char* API_CALL mk_parser_get_url(const mk_parser ctx); -//Parser::FullUrl(),包括?后面的参数 -API_EXPORT const char* API_CALL mk_parser_get_full_url(const mk_parser ctx); //Parser::Params(),?后面的参数字符串 API_EXPORT const char* API_CALL mk_parser_get_url_params(const mk_parser ctx); //Parser::getUrlArgs()["key"],获取?后面的参数中的特定参数 diff --git a/api/source/mk_events_objects.cpp b/api/source/mk_events_objects.cpp index 399f025c..c39a84d6 100644 --- a/api/source/mk_events_objects.cpp +++ b/api/source/mk_events_objects.cpp @@ -90,11 +90,6 @@ API_EXPORT const char* API_CALL mk_parser_get_url(const mk_parser ctx){ Parser *parser = (Parser *)ctx; return parser->Url().c_str(); } -API_EXPORT const char* API_CALL mk_parser_get_full_url(const mk_parser ctx){ - assert(ctx); - Parser *parser = (Parser *)ctx; - return parser->FullUrl().c_str(); -} API_EXPORT const char* API_CALL mk_parser_get_url_params(const mk_parser ctx){ assert(ctx); Parser *parser = (Parser *)ctx; diff --git a/src/Common/Parser.cpp b/src/Common/Parser.cpp index 307e80ff..24a46deb 100644 --- a/src/Common/Parser.cpp +++ b/src/Common/Parser.cpp @@ -49,16 +49,16 @@ void Parser::Parse(const char *buf) { } if (start == buf) { _strMethod = FindField(line.data(), NULL, " "); - _strFullUrl = FindField(line.data(), " ", " "); - auto args_pos = _strFullUrl.find('?'); + auto strFullUrl = FindField(line.data(), " ", " "); + auto args_pos = strFullUrl.find('?'); if (args_pos != string::npos) { - _strUrl = _strFullUrl.substr(0, args_pos); - _params = _strFullUrl.substr(args_pos + 1); + _strUrl = strFullUrl.substr(0, args_pos); + _params = strFullUrl.substr(args_pos + 1); _mapUrlArgs = parseArgs(_params); } else { - _strUrl = _strFullUrl; + _strUrl = strFullUrl; } - _strTail = FindField(line.data(), (_strFullUrl + " ").data(), NULL); + _strTail = FindField(line.data(), (strFullUrl + " ").data(), NULL); } else { auto field = FindField(line.data(), NULL, ": "); auto value = FindField(line.data(), ": ", NULL); @@ -82,8 +82,11 @@ const string &Parser::Url() const { return _strUrl; } -const string &Parser::FullUrl() const { - return _strFullUrl; +string Parser::FullUrl() const { + if (_params.empty()) { + return _strUrl; + } + return _strUrl + "?" + _params; } const string &Parser::Tail() const { @@ -105,7 +108,6 @@ const string &Parser::Content() const { void Parser::Clear() { _strMethod.clear(); _strUrl.clear(); - _strFullUrl.clear(); _params.clear(); _strTail.clear(); _strContent.clear(); diff --git a/src/Common/Parser.h b/src/Common/Parser.h index 3f4d078b..24d12749 100644 --- a/src/Common/Parser.h +++ b/src/Common/Parser.h @@ -69,7 +69,7 @@ public: //获取中间url,不包含?后面的参数 const string &Url() const; //获取中间url,包含?后面的参数 - const string &FullUrl() const; + string FullUrl() const; //获取命令协议名 const string &Tail() const; //根据header key名,获取请求header value值 @@ -96,7 +96,6 @@ private: string _strTail; string _strContent; string _strNull; - string _strFullUrl; string _params; mutable StrCaseMap _mapHeaders; mutable StrCaseMap _mapUrlArgs;