mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-03 12:18:11 +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
|
||||
req = HttpRequest::newHttpJsonRequest(json);
|
||||
assert(req->jsonObject());
|
||||
req->setMethod(drogon::Post);
|
||||
req->setPath("/api/v1/apitest/json");
|
||||
client->sendRequest(req,
|
||||
|
@ -29,9 +29,9 @@ void HttpRequestImpl::parseJson() const
|
||||
auto input = contentView();
|
||||
if (input.empty())
|
||||
return;
|
||||
std::string type = getHeaderBy("content-type");
|
||||
std::transform(type.begin(), type.end(), type.begin(), tolower);
|
||||
if (type.find("application/json") != std::string::npos)
|
||||
if (contentType_ == CT_APPLICATION_JSON ||
|
||||
getHeaderBy("content-type").find("application/json") !=
|
||||
std::string::npos)
|
||||
{
|
||||
static std::once_flag once;
|
||||
static Json::CharReaderBuilder builder;
|
||||
@ -48,6 +48,10 @@ void HttpRequestImpl::parseJson() const
|
||||
jsonPtr_.reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonPtr_.reset();
|
||||
}
|
||||
}
|
||||
void HttpRequestImpl::parseParameters() const
|
||||
{
|
||||
@ -628,4 +632,4 @@ void HttpRequestImpl::reserveBodySize()
|
||||
.append(fileName);
|
||||
cacheFilePtr_ = std::make_unique<CacheFile>(tmpfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user