mirror of https://github.com/aria2/aria2
2007-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use filename and size from Metalink file instead of sending HEAD request: * src/UrlRequestInfo.h (_filename): New variable. (_totalLength): New variable. (setTotalLength): New variable. (setFilename): New variable. * src/MetalinkRequestInfo.cc (execute): Set filename and size to UrlRequestInfo * src/UrlRequestInfo.cc (execute): Use filename and size from Metalink instead of seding HEAD request to servers.pull/1/head
parent
460c874e26
commit
228ed66f73
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2007-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Use filename and size from Metalink file instead of sending HEAD
|
||||||
|
request:
|
||||||
|
* src/UrlRequestInfo.h
|
||||||
|
(_filename): New variable.
|
||||||
|
(_totalLength): New variable.
|
||||||
|
(setTotalLength): New variable.
|
||||||
|
(setFilename): New variable.
|
||||||
|
* src/MetalinkRequestInfo.cc
|
||||||
|
(execute): Set filename and size to UrlRequestInfo
|
||||||
|
* src/UrlRequestInfo.cc
|
||||||
|
(execute): Use filename and size from Metalink instead of seding
|
||||||
|
HEAD request to servers.
|
||||||
|
|
||||||
2007-03-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2007-03-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
To add the ability to resume downloading a partially downloaded file
|
To add the ability to resume downloading a partially downloaded file
|
||||||
|
|
|
@ -122,6 +122,8 @@ RequestInfos MetalinkRequestInfo::execute() {
|
||||||
urls.push_back((*itr)->url);
|
urls.push_back((*itr)->url);
|
||||||
}
|
}
|
||||||
UrlRequestInfoHandle reqInfo = new UrlRequestInfo(urls, maxConnection, op);
|
UrlRequestInfoHandle reqInfo = new UrlRequestInfo(urls, maxConnection, op);
|
||||||
|
reqInfo->setFilename(entry->filename);
|
||||||
|
reqInfo->setTotalLength(entry->size);
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
reqInfo->setChecksum(checksum);
|
reqInfo->setChecksum(checksum);
|
||||||
if(!entry->chunkChecksum.isNull()) {
|
if(!entry->chunkChecksum.isNull()) {
|
||||||
|
|
|
@ -159,13 +159,19 @@ RequestInfos UrlRequestInfo::execute() {
|
||||||
|
|
||||||
RequestInfo* next = 0;
|
RequestInfo* next = 0;
|
||||||
try {
|
try {
|
||||||
HeadResultHandle hr = getHeadResult();
|
HeadResultHandle hr(0);
|
||||||
|
if(_totalLength == 0 || _filename.length() == 0) {
|
||||||
|
hr = getHeadResult();
|
||||||
|
|
||||||
if(hr.isNull()) {
|
if(hr.isNull()) {
|
||||||
logger->notice("No URI to download. Download aborted.");
|
logger->notice(MSG_NO_URL_TO_DOWNLOAD);
|
||||||
return RequestInfos();
|
return RequestInfos();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
hr = new HeadResult();
|
||||||
|
hr->filename = _filename;
|
||||||
|
hr->totalLength = _totalLength;
|
||||||
|
}
|
||||||
logger->info("Head result: filename=%s, total length=%s",
|
logger->info("Head result: filename=%s, total length=%s",
|
||||||
hr->filename.c_str(), Util::ullitos(hr->totalLength, true).c_str());
|
hr->filename.c_str(), Util::ullitos(hr->totalLength, true).c_str());
|
||||||
|
|
||||||
|
@ -174,6 +180,11 @@ RequestInfos UrlRequestInfo::execute() {
|
||||||
op->get(PREF_REFERER),
|
op->get(PREF_REFERER),
|
||||||
op->getAsInt(PREF_SPLIT)));
|
op->getAsInt(PREF_SPLIT)));
|
||||||
|
|
||||||
|
if(requests.size() == 0) {
|
||||||
|
logger->notice(MSG_NO_URL_TO_DOWNLOAD);
|
||||||
|
return RequestInfos();
|
||||||
|
}
|
||||||
|
|
||||||
adjustRequestSize(requests, reserved, maxConnections);
|
adjustRequestSize(requests, reserved, maxConnections);
|
||||||
|
|
||||||
SharedHandle<ConsoleDownloadEngine> e(DownloadEngineFactory::newConsoleEngine(op, requests, reserved));
|
SharedHandle<ConsoleDownloadEngine> e(DownloadEngineFactory::newConsoleEngine(op, requests, reserved));
|
||||||
|
|
|
@ -53,6 +53,8 @@ class UrlRequestInfo : public RequestInfo {
|
||||||
private:
|
private:
|
||||||
Strings urls;
|
Strings urls;
|
||||||
int maxConnections;
|
int maxConnections;
|
||||||
|
string _filename;
|
||||||
|
int64_t _totalLength;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
MessageDigestContext::DigestAlgo digestAlgo;
|
MessageDigestContext::DigestAlgo digestAlgo;
|
||||||
int32_t chunkChecksumLength;
|
int32_t chunkChecksumLength;
|
||||||
|
@ -69,7 +71,8 @@ public:
|
||||||
UrlRequestInfo(const Strings& urls, int maxConnections, Option* op):
|
UrlRequestInfo(const Strings& urls, int maxConnections, Option* op):
|
||||||
RequestInfo(op),
|
RequestInfo(op),
|
||||||
urls(urls),
|
urls(urls),
|
||||||
maxConnections(maxConnections)
|
maxConnections(maxConnections),
|
||||||
|
_totalLength(0)
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
,
|
,
|
||||||
digestAlgo(DIGEST_ALGO_SHA1),
|
digestAlgo(DIGEST_ALGO_SHA1),
|
||||||
|
@ -98,6 +101,16 @@ public:
|
||||||
this->chunkChecksums = chunkChecksums;
|
this->chunkChecksums = chunkChecksums;
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
|
void setTotalLength(int64_t totalLength)
|
||||||
|
{
|
||||||
|
_totalLength = totalLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFilename(const string& filename)
|
||||||
|
{
|
||||||
|
_filename = filename;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<UrlRequestInfo> UrlRequestInfoHandle;
|
typedef SharedHandle<UrlRequestInfo> UrlRequestInfoHandle;
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
#define MSG_SAVED_SEGMENT_FILE _("The segment file was saved successfully.")
|
#define MSG_SAVED_SEGMENT_FILE _("The segment file was saved successfully.")
|
||||||
#define MSG_LOADING_SEGMENT_FILE _("Loading the segment file %s.")
|
#define MSG_LOADING_SEGMENT_FILE _("Loading the segment file %s.")
|
||||||
#define MSG_LOADED_SEGMENT_FILE _("The segment file was loaded successfully.")
|
#define MSG_LOADED_SEGMENT_FILE _("The segment file was loaded successfully.")
|
||||||
|
#define MSG_NO_URL_TO_DOWNLOAD _("No URI to download. Download aborted.")
|
||||||
|
|
||||||
#define EX_TIME_OUT _("Timeout.")
|
#define EX_TIME_OUT _("Timeout.")
|
||||||
#define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.")
|
#define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.")
|
||||||
|
|
Loading…
Reference in New Issue