From ca54cb9d31dfed7166d7aaf43cc65b9217757ed1 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 5 May 2017 23:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=AD=E7=82=B9=E7=BB=AD?= =?UTF-8?q?=E4=BC=A0=E8=BF=94=E5=9B=9E416=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpDownloader.cpp | 5 +++++ src/Http/HttpDownloader.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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(); //开始下载文件,默认断点续传方式下载