mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 11:41:44 +08:00
适配ZLToolKit develop分支
This commit is contained in:
@@ -44,6 +44,7 @@ HttpDownloader::~HttpDownloader() {
|
||||
void HttpDownloader::startDownload(const string& url, const string& filePath,bool bAppend,uint32_t timeOutSecond) {
|
||||
_filePath = filePath;
|
||||
_timeOutSecond = timeOutSecond;
|
||||
_downloadTicker.resetTime();
|
||||
if(_filePath.empty()){
|
||||
_filePath = exeDir() + "HttpDownloader/" + MD5(url).hexdigest();
|
||||
}
|
||||
@@ -67,7 +68,8 @@ void HttpDownloader::startDownload(const string& url, const string& filePath,boo
|
||||
}
|
||||
|
||||
void HttpDownloader::onResponseHeader(const string& status,const HttpHeader& headers) {
|
||||
if(status != "200" && status != "206"){
|
||||
_downloadTicker.resetTime();
|
||||
if(status != "200" && status != "206"){
|
||||
//失败
|
||||
shutdown();
|
||||
closeFile();
|
||||
@@ -81,7 +83,8 @@ void HttpDownloader::onResponseHeader(const string& status,const HttpHeader& hea
|
||||
}
|
||||
|
||||
void HttpDownloader::onResponseBody(const char* buf, size_t size, size_t recvedSize, size_t totalSize) {
|
||||
if(_saveFile){
|
||||
_downloadTicker.resetTime();
|
||||
if(_saveFile){
|
||||
fwrite(buf,size,1,_saveFile);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +129,7 @@ void HttpDownloader::closeFile() {
|
||||
}
|
||||
|
||||
void HttpDownloader::onManager(){
|
||||
if(elapsedTime() > _timeOutSecond * 1000){
|
||||
if(_downloadTicker.elapsedTime() > _timeOutSecond * 1000){
|
||||
//超时
|
||||
onDisconnect(SockException(Err_timeout,"download timeout"));
|
||||
shutdown();
|
||||
|
||||
Reference in New Issue
Block a user