diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index be36a863..88bc73aa 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit be36a8637a53c707e8cc293b66e153edde55afa1 +Subproject commit 88bc73aa6b7e04e04ca45f4fdbe36d4e359088bf diff --git a/src/Http/HttpClient.cpp b/src/Http/HttpClient.cpp index f9117e8b..e4829429 100644 --- a/src/Http/HttpClient.cpp +++ b/src/Http/HttpClient.cpp @@ -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) { diff --git a/src/Http/HttpClient.h b/src/Http/HttpClient.h index 4e32dbf1..69d7ff46 100644 --- a/src/Http/HttpClient.h +++ b/src/Http/HttpClient.h @@ -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;