解决断点续传返回416的问题

This commit is contained in:
xiongziliang
2017-05-05 23:54:30 +08:00
parent ae4c724005
commit ca54cb9d31
2 changed files with 6 additions and 1 deletions

View File

@@ -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");