diff --git a/src/Http/HttpDownloader.cpp b/src/Http/HttpDownloader.cpp index 1d352080..d6162ee4 100644 --- a/src/Http/HttpDownloader.cpp +++ b/src/Http/HttpDownloader.cpp @@ -34,6 +34,11 @@ void HttpDownloader::startDownload(const string& url, const string& filePath,boo } if(bAppend){ auto currentLen = ftell(_saveFile); + if(currentLen){ + //最少续传一个字节,怕遇到http 416的错误 + currentLen -= 1; + fseek(_saveFile,-1,SEEK_CUR); + } addHeader("Range", StrPrinter << "bytes=" << currentLen << "-" << endl); } setMethod("GET"); diff --git a/src/Http/HttpDownloader.h b/src/Http/HttpDownloader.h index 93a04c19..ba890f0e 100644 --- a/src/Http/HttpDownloader.h +++ b/src/Http/HttpDownloader.h @@ -16,7 +16,7 @@ namespace Http { class HttpDownloader: public HttpClientImp { public: typedef std::shared_ptr Ptr; - typedef std::function onDownloadResult; + typedef std::function onDownloadResult; HttpDownloader(); virtual ~HttpDownloader(); //开始下载文件,默认断点续传方式下载