mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
Add http pipelining request support (#3154)
Support recv multi http request before reponse it. Co-authored-by: 夏楚 <771730766@qq.com>
This commit is contained in:
parent
8f4e76406c
commit
9d68b668fc
@ -124,29 +124,18 @@ ssize_t HttpSession::onRecvHeader(const char *header, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//// body size明确指定且小于最大值的情况 ////
|
//// body size明确指定且小于最大值的情况 ////
|
||||||
auto body = std::make_shared<std::string>();
|
_on_recv_body = [this, it](const char *data, size_t len) mutable {
|
||||||
// 预留一定的内存buffer,防止频繁的内存拷贝
|
|
||||||
body->reserve(content_len);
|
|
||||||
|
|
||||||
_on_recv_body = [this, body, content_len, it](const char *data, size_t len) mutable {
|
|
||||||
body->append(data, len);
|
|
||||||
if (body->size() < content_len) {
|
|
||||||
// 未收满数据
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 收集body完毕
|
// 收集body完毕
|
||||||
_parser.setContent(std::move(*body));
|
_parser.setContent(std::string(data, len));
|
||||||
(this->*(it->second))();
|
(this->*(it->second))();
|
||||||
_parser.clear();
|
_parser.clear();
|
||||||
|
|
||||||
// 后续是header
|
// _on_recv_body置空
|
||||||
setContentLen(0);
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 声明后续都是body;Http body在本对象缓冲,不通过HttpRequestSplitter保存
|
// 声明body长度,通过HttpRequestSplitter缓存然后一次性回调到_on_recv_body
|
||||||
return -1;
|
return content_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpSession::onRecvContent(const char *data, size_t len) {
|
void HttpSession::onRecvContent(const char *data, size_t len) {
|
||||||
|
Loading…
Reference in New Issue
Block a user