Fix a error in HttpClient (#262)

This commit is contained in:
An Tao 2019-10-01 00:58:30 +08:00 committed by GitHub
parent 70eda27427
commit 56b9a320b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -203,6 +203,10 @@ bool HttpResponseParser::parseResponse(MsgBuffer *buf)
}
else if (_state == HttpResponseParseState::kExpectClose)
{
if (!_response->_bodyPtr)
{
_response->_bodyPtr = std::make_shared<std::string>();
}
_response->_bodyPtr->append(
std::string(buf->peek(), buf->readableBytes()));
buf->retrieveAll();
@ -242,6 +246,10 @@ bool HttpResponseParser::parseResponse(MsgBuffer *buf)
if (*(buf->peek() + _response->_currentChunkLength) == '\r' &&
*(buf->peek() + _response->_currentChunkLength + 1) == '\n')
{
if (!_response->_bodyPtr)
{
_response->_bodyPtr = std::make_shared<std::string>();
}
_response->_bodyPtr->append(
std::string(buf->peek(),
_response->_currentChunkLength));

@ -1 +1 @@
Subproject commit 1f4b6398e8c575341d4fbf6927d0b050d99fb05a
Subproject commit e95f82d3090f81b4f5b7610b4e0e6e609c734509