mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-11-29 18:27:43 +08:00
Merge pull request #153 from an-tao/dev
Modify the HttpRequestParser class to improve performance
This commit is contained in:
commit
3647f8c80e
@ -214,6 +214,7 @@ bool HttpRequestParser::parseRequest(MsgBuffer *buf)
|
||||
shutdownConnection(k413RequestEntityTooLarge);
|
||||
return false;
|
||||
}
|
||||
_request->_content.reserve(_request->_contentLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -251,12 +252,12 @@ bool HttpRequestParser::parseRequest(MsgBuffer *buf)
|
||||
if (_request->_contentLen >= buf->readableBytes())
|
||||
{
|
||||
_request->_contentLen -= buf->readableBytes();
|
||||
_request->_content += std::string(buf->peek(), buf->readableBytes());
|
||||
_request->_content.append(buf->peek(), buf->readableBytes());
|
||||
buf->retrieveAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
_request->_content += std::string(buf->peek(), _request->_contentLen);
|
||||
_request->_content.append(buf->peek(), _request->_contentLen);
|
||||
buf->retrieve(_request->_contentLen);
|
||||
_request->_contentLen = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user