mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
HTTP: 确保http请求结束后不再触发超时事件
This commit is contained in:
parent
f89abfaf67
commit
0bf75529a2
@ -1 +1 @@
|
||||
Subproject commit be36a8637a53c707e8cc293b66e153edde55afa1
|
||||
Subproject commit 88bc73aa6b7e04e04ca45f4fdbe36d4e359088bf
|
@ -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) {
|
||||
|
@ -106,6 +106,11 @@ public:
|
||||
*/
|
||||
const string &getUrl() const;
|
||||
|
||||
/**
|
||||
* 判断是否正在等待响应
|
||||
*/
|
||||
bool waitResponse() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* 收到http回复头
|
||||
@ -173,6 +178,7 @@ protected:
|
||||
bool _is_https;
|
||||
|
||||
private:
|
||||
bool _complete = false;
|
||||
string _url;
|
||||
HttpHeader _header;
|
||||
HttpBody::Ptr _body;
|
||||
|
Loading…
Reference in New Issue
Block a user