diff --git a/lib/src/HttpRequestImpl.cc b/lib/src/HttpRequestImpl.cc index ee21f41d..03748595 100755 --- a/lib/src/HttpRequestImpl.cc +++ b/lib/src/HttpRequestImpl.cc @@ -17,12 +17,13 @@ #include using namespace drogon; -void HttpRequestImpl::parsePremeter() +void HttpRequestImpl::parseParameter() { - std::string type = getHeaderBy("content-type"); - - std::transform(type.begin(), type.end(), type.begin(), tolower); const std::string &input = query(); + if(input.empty()) + return; + std::string type = getHeaderBy("content-type"); + std::transform(type.begin(), type.end(), type.begin(), tolower); if (_method == Get || (_method == Post && (type == "" || type.find("application/x-www-form-urlencoded") != std::string::npos))) { @@ -82,11 +83,11 @@ void HttpRequestImpl::parsePremeter() _jsonPtr.reset(); } } - LOG_TRACE << "_parameters:"; - for (auto iter : _parameters) - { - LOG_TRACE << iter.first << "=" << iter.second; - } + // LOG_TRACE << "_parameters:"; + // for (auto iter : _parameters) + // { + // LOG_TRACE << iter.first << "=" << iter.second; + // } } void HttpRequestImpl::appendToBuffer(MsgBuffer *output) const diff --git a/lib/src/HttpRequestImpl.h b/lib/src/HttpRequestImpl.h index 44d704cd..d32b534b 100755 --- a/lib/src/HttpRequestImpl.h +++ b/lib/src/HttpRequestImpl.h @@ -50,7 +50,7 @@ class HttpRequestImpl : public HttpRequest { return _version; } - void parsePremeter(); + void parseParameter(); bool setMethod(const char *start, const char *end) { @@ -135,7 +135,15 @@ class HttpRequestImpl : public HttpRequest void setPath(const char *start, const char *end) { - _path = urlDecode(std::string(start, end)); + auto path = std::string(start, end); + if (path.find('+') != std::string::npos || path.find('%') != std::string::npos) + { + _path = urlDecode(path); + } + else + { + _path = path; + } } virtual void setPath(const std::string &path) override { diff --git a/lib/src/HttpServer.cc b/lib/src/HttpServer.cc index d8ccf8d4..38108366 100755 --- a/lib/src/HttpServer.cc +++ b/lib/src/HttpServer.cc @@ -113,7 +113,7 @@ void HttpServer::onMessage(const TcpConnectionPtr &conn, if (context->gotAll()) { - context->requestImpl()->parsePremeter(); + context->requestImpl()->parseParameter(); context->requestImpl()->setPeerAddr(conn->peerAddr()); context->requestImpl()->setLocalAddr(conn->localAddr()); context->requestImpl()->setReceiveDate(trantor::Date::date());