mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 11:41:44 +08:00
Http客户端添加超时功能
This commit is contained in:
@@ -41,8 +41,9 @@ HttpDownloader::~HttpDownloader() {
|
||||
closeFile();
|
||||
}
|
||||
|
||||
void HttpDownloader::startDownload(const string& url, const string& filePath,bool bAppend) {
|
||||
void HttpDownloader::startDownload(const string& url, const string& filePath,bool bAppend,uint32_t timeOutSecond) {
|
||||
_filePath = filePath;
|
||||
_timeOutSecond = timeOutSecond;
|
||||
if(_filePath.empty()){
|
||||
_filePath = exeDir() + "HttpDownloader/" + MD5(url).hexdigest();
|
||||
}
|
||||
@@ -124,5 +125,14 @@ void HttpDownloader::closeFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void HttpDownloader::onManager(){
|
||||
if(elapsedTime() > _timeOutSecond * 1000){
|
||||
//超时
|
||||
onDisconnect(SockException(Err_timeout,"download timeout"));
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* namespace Http */
|
||||
} /* namespace ZL */
|
||||
|
||||
Reference in New Issue
Block a user