diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-09-22 23:19:41 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-09-22 23:19:41 +0900 |
| commit | 461a542c5e236a22bb4edba3fae9610df4ba44c6 (patch) | |
| tree | 47898cc7a938ff49866b8889095b651c54e3df3c /src/HttpRequest.cc | |
| parent | 9d294741fd1bb469ed6be4e46af2f6521ce75054 (diff) | |
Rewritten DownloadHandlerConstants
DownloadHandlerConstants was simplified. MIME type handling in Accept
header was also reworked. DownloadContext's metalinkServerContacted_
is replaced with acceptMetalink_ and its boolean value is reverted.
RequestGroup and HttpRequest now do not hold vector of accepting
types. HttpRequest has the flag acceptMetalink_ which will be set by
the same value of DownloadContext::accpetMetalink_ and if it is true,
Metalink MIME types are added to Accept header field.
Diffstat (limited to 'src/HttpRequest.cc')
| -rw-r--r-- | src/HttpRequest.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 4a1593d1..09254d1c 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -51,6 +51,7 @@ #include "TimeA2.h" #include "array_fun.h" #include "Request.h" +#include "DownloadHandlerConstants.h" namespace aria2 { @@ -58,6 +59,7 @@ const std::string HttpRequest::USER_AGENT("aria2"); HttpRequest::HttpRequest():contentEncodingEnabled_(true), userAgent_(USER_AGENT), + acceptMetalink_(false), noCache_(true), acceptGzip_(false), endOffsetOverride_(0) @@ -164,10 +166,13 @@ std::string HttpRequest::createRequest() builtinHds.reserve(20); builtinHds.push_back(std::make_pair("User-Agent:", userAgent_)); std::string acceptTypes = "*/*"; - for(std::vector<std::string>::const_iterator i = acceptTypes_.begin(), - eoi = acceptTypes_.end(); i != eoi; ++i) { - acceptTypes += ","; - acceptTypes += *i; + if(acceptMetalink_) { + // The mime types of Metalink are used for "transparent metalink". + const char** metalinkTypes = getMetalinkContentTypes(); + for(size_t i = 0; metalinkTypes[i]; ++i) { + acceptTypes += ","; + acceptTypes += metalinkTypes[i]; + } } builtinHds.push_back(std::make_pair("Accept:", acceptTypes)); if(contentEncodingEnabled_) { @@ -328,11 +333,6 @@ void HttpRequest::clearHeader() headers_.clear(); } -void HttpRequest::addAcceptType(const std::string& type) -{ - acceptTypes_.push_back(type); -} - void HttpRequest::setCookieStorage (const SharedHandle<CookieStorage>& cookieStorage) { |
