2010-01-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added --http-no-cache option.  When true is given, aria2 sends
	Cache-Control: no-cache and Pragma: no-cache header to avoid
	cached content.  If false is given , these headers are not sent
	and you can add Cache-Control header with a directive you like
	using --header option.
	* src/HttpRequest.cc
	* src/HttpRequest.h
	* src/HttpRequestCommand.cc
	* src/OptionHandlerFactory.cc
	* src/download_helper.cc
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
pull/1/head
Tatsuhiro Tsujikawa 2010-01-10 07:33:20 +00:00
parent 84389aefe2
commit 658442b762
9 changed files with 59 additions and 5 deletions

View File

@ -1,3 +1,19 @@
2010-01-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --http-no-cache option. When true is given, aria2 sends
Cache-Control: no-cache and Pragma: no-cache header to avoid
cached content. If false is given , these headers are not sent
and you can add Cache-Control header with a directive you like
using --header option.
* src/HttpRequest.cc
* src/HttpRequest.h
* src/HttpRequestCommand.cc
* src/OptionHandlerFactory.cc
* src/download_helper.cc
* src/prefs.cc
* src/prefs.h
* src/usage_text.h
2010-01-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed Logger from OptionParser. When OptionParser is used to

View File

@ -55,7 +55,8 @@ namespace aria2 {
const std::string HttpRequest::USER_AGENT("aria2");
HttpRequest::HttpRequest():_contentEncodingEnabled(true),
userAgent(USER_AGENT)
userAgent(USER_AGENT),
_noCache(true)
{}
void HttpRequest::setSegment(const SharedHandle<Segment>& segment)
@ -174,9 +175,10 @@ std::string HttpRequest::createRequest()
}
strappend(requestLine, "Host: ", getHostText(getURIHost(), getPort()), "\r\n");
requestLine += "Pragma: no-cache\r\n";
requestLine += "Cache-Control: no-cache\r\n";
if(_noCache) {
requestLine += "Pragma: no-cache\r\n";
requestLine += "Cache-Control: no-cache\r\n";
}
if(!request->isKeepAliveEnabled() && !request->isPipeliningEnabled()) {
requestLine += "Connection: close\r\n";
}

View File

@ -83,6 +83,8 @@ private:
SharedHandle<Request> _proxyRequest;
bool _noCache;
std::string getProxyAuthString() const;
public:
HttpRequest();
@ -243,6 +245,16 @@ public:
{
return _fileEntry;
}
void enableNoCache()
{
_noCache = true;
}
void disableNoCache()
{
_noCache = false;
}
};
typedef SharedHandle<HttpRequest> HttpRequestHandle;

View File

@ -96,7 +96,11 @@ createHttpRequest(const SharedHandle<Request>& req,
httpRequest->setProxyRequest(proxyRequest);
httpRequest->addAcceptType(rg->getAcceptTypes().begin(),
rg->getAcceptTypes().end());
if(option->getAsBool(PREF_HTTP_NO_CACHE)) {
httpRequest->enableNoCache();
} else {
httpRequest->disableNoCache();
}
return httpRequest;
}

View File

@ -707,6 +707,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_HTTP);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new BooleanOptionHandler
(PREF_HTTP_NO_CACHE,
TEXT_HTTP_NO_CACHE,
V_TRUE,
OptionHandler::OPT_ARG));
op->addTag(TAG_HTTP);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new DefaultOptionHandler
(PREF_HTTP_PASSWD,

View File

@ -89,6 +89,7 @@ const std::set<std::string>& listRequestOptions()
PREF_SPLIT,
PREF_TIMEOUT,
PREF_HTTP_AUTH_CHALLENGE,
PREF_HTTP_NO_CACHE,
PREF_HTTP_USER,
PREF_HTTP_PASSWD,
PREF_HTTP_PROXY,

View File

@ -222,6 +222,8 @@ const std::string PREF_CHECK_CERTIFICATE("check-certificate");
const std::string PREF_USE_HEAD("use-head");
// value: true | false
const std::string PREF_HTTP_AUTH_CHALLENGE("http-auth-challenge");
// value: true | false
const std::string PREF_HTTP_NO_CACHE("http-no-cache");
/**
* Proxy related preferences

View File

@ -226,6 +226,8 @@ extern const std::string PREF_CHECK_CERTIFICATE;
extern const std::string PREF_USE_HEAD;
// value: true | false
extern const std::string PREF_HTTP_AUTH_CHALLENGE;
// value: true | false
extern const std::string PREF_HTTP_NO_CACHE;
/**;
* Proxy related preferences

View File

@ -590,3 +590,9 @@
" .torrent. The directory to be saved is the same\n" \
" directory where download file is saved. If the\n" \
" same file already exists, metadata is not saved.")
#define TEXT_HTTP_NO_CACHE \
_(" --http-no-cache[=true|false] Send Cache-Control: no-cache and Pragma: no-cache\n" \
" header to avoid cached content. If false is given\n" \
" , these headers are not sent and you can add\n" \
" Cache-Control header with a directive you like\n" \
" using --header option.")