Fix a bug when converting the content-length string to size_t (#1355)

This commit is contained in:
An Tao 2022-08-19 14:20:37 +08:00 committed by GitHub
parent 64b9484657
commit f582a16adb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -216,7 +216,8 @@ bool HttpRequestParser::parseRequest(MsgBuffer *buf)
{
try
{
currentContentLength_ = std::stoull(len.c_str());
currentContentLength_ =
static_cast<size_t>(std::stoull(len));
}
catch (...)
{

View File

@ -127,7 +127,7 @@ bool HttpResponseParser::parseResponse(MsgBuffer *buf)
// LOG_INFO << "content len=" << len;
if (!len.empty())
{
leftBodyLength_ = atoi(len.c_str());
leftBodyLength_ = static_cast<size_t>(std::stoull(len));
status_ = HttpResponseParseStatus::kExpectBody;
}
else