mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
优化http服务器和客户端内存占用
This commit is contained in:
parent
74621618ff
commit
5dfb7663e4
@ -186,7 +186,7 @@ int64_t HttpClient::onRecvHeader(const char *data, uint64_t len) {
|
||||
//所以返回-1代表我们接下来分段接收content
|
||||
_recvedBodySize = 0;
|
||||
//根据_totalBodySize设置接收缓存大小
|
||||
_sock->setReadBuffer(std::make_shared<BufferRaw>(MAX(_totalBodySize + 1,256 * 1024)));
|
||||
_sock->setReadBuffer(std::make_shared<BufferRaw>(MIN(_totalBodySize + 1,256 * 1024)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -635,6 +635,14 @@ inline bool HttpSession::Handle_Req_POST(int64_t &content_len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//根据Content-Length设置接收缓存大小
|
||||
if(totalContentLen > 0){
|
||||
_sock->setReadBuffer(std::make_shared<BufferRaw>(MIN(totalContentLen + 1,256 * 1024)));
|
||||
}else{
|
||||
//不定长度的Content-Length
|
||||
_sock->setReadBuffer(std::make_shared<BufferRaw>(256 * 1024));
|
||||
}
|
||||
|
||||
if(totalContentLen > 0 && totalContentLen < maxReqSize ){
|
||||
//返回固定长度的content
|
||||
content_len = totalContentLen;
|
||||
@ -652,9 +660,6 @@ inline bool HttpSession::Handle_Req_POST(int64_t &content_len) {
|
||||
return false;
|
||||
};
|
||||
}else{
|
||||
//如果是post请求 并且totalContentLen数据超过maxReqSize,那么我们加大接收缓存提升性能
|
||||
_sock->setReadBuffer(std::make_shared<BufferRaw>(256 * 1024));
|
||||
|
||||
//返回不固定长度的content
|
||||
content_len = -1;
|
||||
auto parserCopy = _parser;
|
||||
|
Loading…
Reference in New Issue
Block a user