diff --git a/ChangeLog b/ChangeLog index cab297d0..5ff7683d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-04-02 Tatsuhiro Tsujikawa + + Made aria2 not send + "application/metalink4+xml,application/metalink+xml" in Accept + header for web-seeding URIs and tracker request. + * src/Metalink2RequestGroup.cc + * src/TrackerWatcherCommand.cc + * src/download_helper.cc + * src/util.cc + * src/util.h + 2010-04-01 Tatsuhiro Tsujikawa Added download_helper.{cc,h} to SRCS diff --git a/src/Metalink2RequestGroup.cc b/src/Metalink2RequestGroup.cc index 2fbceee7..df275a81 100644 --- a/src/Metalink2RequestGroup.cc +++ b/src/Metalink2RequestGroup.cc @@ -54,7 +54,6 @@ #include "FileEntry.h" #include "A2STR.h" #include "a2functional.h" -#include "DownloadHandlerConstants.h" #ifdef ENABLE_BITTORRENT # include "BtDependency.h" # include "download_helper.h" @@ -124,18 +123,6 @@ Metalink2RequestGroup::generate createRequestGroup(groups, entries, option); } -namespace { -void removeMetalinkContentTypes(const SharedHandle& group) -{ - for(std::vector::const_iterator i = - DownloadHandlerConstants::getMetalinkContentTypes().begin(), - eoi = DownloadHandlerConstants::getMetalinkContentTypes().end(); - i != eoi; ++i) { - group->removeAcceptType(*i); - } -} -} - void Metalink2RequestGroup::createRequestGroup (std::vector >& groups, @@ -213,7 +200,7 @@ Metalink2RequestGroup::createRequestGroup torrentRg->clearPostDownloadHandler(); // remove "metalink" from Accept Type list to avoid loop in // tranparent metalink - removeMetalinkContentTypes(torrentRg); + util::removeMetalinkContentTypes(torrentRg); // make it in-memory download SharedHandle preh (new MemoryBufferPreDownloadHandler()); @@ -306,7 +293,7 @@ Metalink2RequestGroup::createRequestGroup rg->setDownloadContext(dctx); // remove "metalink" from Accept Type list to avoid loop in // tranparent metalink - removeMetalinkContentTypes(rg); + util::removeMetalinkContentTypes(rg); #ifdef ENABLE_BITTORRENT // Inject depenency between rg and torrentRg here if // torrentRg.isNull() == false diff --git a/src/TrackerWatcherCommand.cc b/src/TrackerWatcherCommand.cc index 3e10b713..60a7b62a 100644 --- a/src/TrackerWatcherCommand.cc +++ b/src/TrackerWatcherCommand.cc @@ -248,6 +248,7 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri) rg->setDiskWriterFactory(dwf); rg->setFileAllocationEnabled(false); rg->setPreLocalFileCheckEnabled(false); + util::removeMetalinkContentTypes(rg); if(logger->info()) { logger->info("Creating tracker request group GID#%s", util::itos(rg->getGID()).c_str()); diff --git a/src/download_helper.cc b/src/download_helper.cc index 8222b48f..5a642d9e 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -236,6 +236,9 @@ createBtRequestGroup(const std::string& torrentFilePath, ((*i).first, util::applyDir(dctx->getDir(), (*i).second)); } rg->setDownloadContext(dctx); + // Remove "metalink" from Accept Type list to avoid server from + // responding Metalink file for web-seeding URIs. + util::removeMetalinkContentTypes(rg); return rg; } diff --git a/src/util.cc b/src/util.cc index abeb6b20..3ad1b22b 100644 --- a/src/util.cc +++ b/src/util.cc @@ -76,6 +76,8 @@ #include "array_fun.h" #include "a2functional.h" #include "bitfield.h" +#include "DownloadHandlerConstants.h" +#include "RequestGroup.h" #ifdef ENABLE_MESSAGE_DIGEST # include "MessageDigestHelper.h" #endif // ENABLE_MESSAGE_DIGEST @@ -1291,6 +1293,16 @@ bool inSameCidrBlock(const std::string& ip1, const std::string& ip2, int bits) return in1.s_addr == in2.s_addr; } +void removeMetalinkContentTypes(const SharedHandle& group) +{ + for(std::vector::const_iterator i = + DownloadHandlerConstants::getMetalinkContentTypes().begin(), + eoi = DownloadHandlerConstants::getMetalinkContentTypes().end(); + i != eoi; ++i) { + group->removeAcceptType(*i); + } +} + } // namespace util } // namespace aria2 diff --git a/src/util.h b/src/util.h index a139e407..9e1c2a5f 100644 --- a/src/util.h +++ b/src/util.h @@ -62,6 +62,7 @@ class Randomizer; class BitfieldMan; class BinaryStream; class FileEntry; +class RequestGroup; #define STRTOLL(X) strtoll(X, reinterpret_cast(0), 10) #define STRTOULL(X) strtoull(X, reinterpret_cast(0), 10) @@ -392,6 +393,8 @@ bool getCidrPrefix(struct in_addr& in, const std::string& ip, int bits); // Returns true if ip1 and ip2 are in the same CIDR block. bool inSameCidrBlock(const std::string& ip1, const std::string& ip2, int bits); +void removeMetalinkContentTypes(const SharedHandle& group); + } // namespace util } // namespace aria2