HLS: 修复http客户端连接复用导致hls播放异常的bug: #1294

This commit is contained in:
ziyue
2021-12-22 11:33:40 +08:00
parent f27893ffa5
commit 6a044f0726
4 changed files with 32 additions and 13 deletions

View File

@@ -80,20 +80,27 @@ void HttpClient::sendRequest(const string &strUrl, float fTimeOutSec) {
startConnect(host, port, fTimeOutSec);
} else {
SockException ex;
onConnect(ex);
onConnect_l(ex);
}
}
void HttpClient::clear() {
_url.clear();
_header.clear();
_body.reset();
_method.clear();
_path.clear();
_parser.Clear();
_recvedBodySize = 0;
_totalBodySize = 0;
_aliveTicker.resetTime();
_chunkedSplitter.reset();
_fTimeOutSec = 0;
clearResponse();
}
void HttpClient::clearResponse() {
_recvedBodySize = 0;
_totalBodySize = 0;
_parser.Clear();
_chunkedSplitter = nullptr;
HttpRequestSplitter::reset();
}
@@ -131,16 +138,17 @@ const string &HttpClient::getUrl() const {
}
void HttpClient::onConnect(const SockException &ex) {
onConnect_l(ex);
}
void HttpClient::onConnect_l(const SockException &ex) {
_aliveTicker.resetTime();
if (ex) {
onDisconnect(ex);
return;
}
_totalBodySize = 0;
_recvedBodySize = 0;
HttpRequestSplitter::reset();
_chunkedSplitter.reset();
clearResponse();
_StrPrinter printer;
printer << _method + " " << _path + " HTTP/1.1\r\n";
@@ -280,8 +288,6 @@ void HttpClient::onManager() {
}
void HttpClient::onResponseCompleted_l() {
_totalBodySize = 0;
_recvedBodySize = 0;
onResponseCompleted();
}