mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-04 20:57:50 +08:00
Fix null jsonObject from newHttpJsonRequest (#388)
* Fix null jsonObject from newHttpJsonRequest Refer to #372 for the response case as well
This commit is contained in:
parent
9ee00da431
commit
2401c6a88a
@ -193,6 +193,7 @@ void doTest(const HttpClientPtr &client,
|
|||||||
});
|
});
|
||||||
// Post json again
|
// Post json again
|
||||||
req = HttpRequest::newHttpJsonRequest(json);
|
req = HttpRequest::newHttpJsonRequest(json);
|
||||||
|
assert(req->jsonObject());
|
||||||
req->setMethod(drogon::Post);
|
req->setMethod(drogon::Post);
|
||||||
req->setPath("/api/v1/apitest/json");
|
req->setPath("/api/v1/apitest/json");
|
||||||
client->sendRequest(req,
|
client->sendRequest(req,
|
||||||
|
@ -29,9 +29,9 @@ void HttpRequestImpl::parseJson() const
|
|||||||
auto input = contentView();
|
auto input = contentView();
|
||||||
if (input.empty())
|
if (input.empty())
|
||||||
return;
|
return;
|
||||||
std::string type = getHeaderBy("content-type");
|
if (contentType_ == CT_APPLICATION_JSON ||
|
||||||
std::transform(type.begin(), type.end(), type.begin(), tolower);
|
getHeaderBy("content-type").find("application/json") !=
|
||||||
if (type.find("application/json") != std::string::npos)
|
std::string::npos)
|
||||||
{
|
{
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
static Json::CharReaderBuilder builder;
|
static Json::CharReaderBuilder builder;
|
||||||
@ -48,6 +48,10 @@ void HttpRequestImpl::parseJson() const
|
|||||||
jsonPtr_.reset();
|
jsonPtr_.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jsonPtr_.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void HttpRequestImpl::parseParameters() const
|
void HttpRequestImpl::parseParameters() const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user