HTTP: 确保http请求结束后不再触发超时事件

This commit is contained in:
ziyue
2021-12-24 13:10:52 +08:00
parent f89abfaf67
commit 0bf75529a2
3 changed files with 14 additions and 2 deletions

View File

@@ -100,6 +100,7 @@ void HttpClient::clear() {
}
void HttpClient::clearResponse() {
_complete = false;
_recved_body_size = 0;
_total_body_size = 0;
_parser.Clear();
@@ -283,16 +284,21 @@ void HttpClient::onManager() {
onResponseCompleted_l();
}
if (_timeout_second > 0 && _total_timeout_ticker.elapsedTime() > _timeout_second * 1000) {
if (waitResponse() && _timeout_second > 0 && _total_timeout_ticker.elapsedTime() > _timeout_second * 1000) {
//超时
shutdown(SockException(Err_timeout, "http request timeout"));
}
}
void HttpClient::onResponseCompleted_l() {
_complete = true;
onResponseCompleted();
}
bool HttpClient::waitResponse() const {
return !_complete && alive();
}
void HttpClient::checkCookie(HttpClient::HttpHeader &headers) {
//Set-Cookie: IPTV_SERVER=8E03927B-CC8C-4389-BC00-31DBA7EC7B49;expires=Sun, Sep 23 2018 15:07:31 GMT;path=/index/api/
for (auto it_set_cookie = headers.find("Set-Cookie"); it_set_cookie != headers.end(); ++it_set_cookie) {