Add resume option to acsmdownloader

This commit is contained in:
2022-03-23 21:05:56 +01:00
parent 5d3112bc38
commit 2f2e4e193e
7 changed files with 46 additions and 19 deletions

View File

@@ -300,11 +300,11 @@ namespace gourou
appendTextElem(root, "adept:expiration", buffer);
}
ByteArray DRMProcessor::sendRequest(const std::string& URL, const std::string& POSTdata, const char* contentType, std::map<std::string, std::string>* responseHeaders, int fd)
ByteArray DRMProcessor::sendRequest(const std::string& URL, const std::string& POSTdata, const char* contentType, std::map<std::string, std::string>* responseHeaders, int fd, bool resume)
{
if (contentType == 0)
contentType = "";
std::string reply = client->sendHTTPRequest(URL, POSTdata, contentType, responseHeaders, fd);
std::string reply = client->sendHTTPRequest(URL, POSTdata, contentType, responseHeaders, fd, resume);
if (fd) return ByteArray();
@@ -583,7 +583,7 @@ namespace gourou
return new FulfillmentItem(fulfillReply, user);
}
DRMProcessor::ITEM_TYPE DRMProcessor::download(FulfillmentItem* item, std::string path)
DRMProcessor::ITEM_TYPE DRMProcessor::download(FulfillmentItem* item, std::string path, bool resume)
{
ITEM_TYPE res = EPUB;
@@ -592,9 +592,9 @@ namespace gourou
std::map<std::string, std::string> headers;
int fd = createNewFile(path);
int fd = createNewFile(path, !resume);
sendRequest(item->getDownloadURL(), "", 0, &headers, fd);
sendRequest(item->getDownloadURL(), "", 0, &headers, fd, resume);
close(fd);