Added --metalink-base-uri option.

--metalink-uri option specifies base URI to resolve relative URI in
metalink file stored in local disk. If URI points to a directory, URI
must end with '/'.
pull/1/head
Tatsuhiro Tsujikawa 2011-05-14 22:46:04 +09:00
parent ed589ab034
commit 49b032800f
6 changed files with 24 additions and 4 deletions

View File

@ -1692,6 +1692,14 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_METALINK);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new DefaultOptionHandler
(PREF_METALINK_BASE_URI,
TEXT_METALINK_BASE_URI,
NO_DEFAULT_VALUE));
op->addTag(TAG_METALINK);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new BooleanOptionHandler
(PREF_METALINK_ENABLE_UNIQUE_PROTOCOL,

View File

@ -352,11 +352,13 @@ void createRequestGroupForMetalink
if(metalinkData.empty()) {
Metalink2RequestGroup().generate(result,
option->get(PREF_METALINK_FILE),
option);
option,
option->get(PREF_METALINK_BASE_URI));
} else {
SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter());
dw->setString(metalinkData);
Metalink2RequestGroup().generate(result, dw, option);
Metalink2RequestGroup().generate(result, dw, option,
option->get(PREF_METALINK_BASE_URI));
}
}
#endif // ENABLE_METALINK
@ -417,7 +419,8 @@ public:
#ifdef ENABLE_METALINK
else if(!ignoreLocalPath_ && detector_.guessMetalinkFile(uri)) {
try {
Metalink2RequestGroup().generate(requestGroups_, uri, option_);
Metalink2RequestGroup().generate(requestGroups_, uri, option_,
option_->get(PREF_METALINK_BASE_URI));
} catch(RecoverableException& e) {
if(throwOnError_) {
throw;

View File

@ -130,7 +130,8 @@ void showMetalinkFile
(const std::string& uri, const SharedHandle<Option>& op)
{
std::vector<SharedHandle<MetalinkEntry> > metalinkEntries;
metalink::parseAndQuery(metalinkEntries, uri, op.get());
metalink::parseAndQuery(metalinkEntries, uri, op.get(),
op->get(PREF_METALINK_BASE_URI));
std::vector<SharedHandle<FileEntry> > fileEntries;
MetalinkEntry::toFileEntry(fileEntries, metalinkEntries);
util::toStream(fileEntries.begin(), fileEntries.end(), std::cout);

View File

@ -423,5 +423,6 @@ const std::string V_HTTPS("https");
const std::string V_FTP("ftp");
// values: true | false
const std::string PREF_METALINK_ENABLE_UNIQUE_PROTOCOL("metalink-enable-unique-protocol");
const std::string PREF_METALINK_BASE_URI("metalink-base-uri");
} // namespace aria2

View File

@ -427,6 +427,8 @@ extern const std::string V_HTTPS;
extern const std::string V_FTP;
// values: true | false
extern const std::string PREF_METALINK_ENABLE_UNIQUE_PROTOCOL;
// values: a string
extern const std::string PREF_METALINK_BASE_URI;
} // namespace aria2

View File

@ -782,3 +782,8 @@
_(" --xml-rpc-listen-port=PORT Deprecated. Use --rpc-listen-port instead.")
#define TEXT_SHOW_CONSOLE_READOUT \
_(" --show-console-readout[=true|false] Show console readout.")
#define TEXT_METALINK_BASE_URI \
_(" --metalink-base-uri=URI Specify base URI to resolve relative URI in\n" \
" metalink:url and metalink:metaurl element in a\n" \
" metalink file stored in local disk. If URI points\n" \
" to a directory, URI must end with '/'.")