mirror of https://github.com/aria2/aria2
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.hpull/1/head
parent
84389aefe2
commit
658442b762
16
ChangeLog
16
ChangeLog
|
@ -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>
|
2010-01-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Removed Logger from OptionParser. When OptionParser is used to
|
Removed Logger from OptionParser. When OptionParser is used to
|
||||||
|
|
|
@ -55,7 +55,8 @@ namespace aria2 {
|
||||||
const std::string HttpRequest::USER_AGENT("aria2");
|
const std::string HttpRequest::USER_AGENT("aria2");
|
||||||
|
|
||||||
HttpRequest::HttpRequest():_contentEncodingEnabled(true),
|
HttpRequest::HttpRequest():_contentEncodingEnabled(true),
|
||||||
userAgent(USER_AGENT)
|
userAgent(USER_AGENT),
|
||||||
|
_noCache(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void HttpRequest::setSegment(const SharedHandle<Segment>& segment)
|
void HttpRequest::setSegment(const SharedHandle<Segment>& segment)
|
||||||
|
@ -174,9 +175,10 @@ std::string HttpRequest::createRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
strappend(requestLine, "Host: ", getHostText(getURIHost(), getPort()), "\r\n");
|
strappend(requestLine, "Host: ", getHostText(getURIHost(), getPort()), "\r\n");
|
||||||
requestLine += "Pragma: no-cache\r\n";
|
if(_noCache) {
|
||||||
requestLine += "Cache-Control: no-cache\r\n";
|
requestLine += "Pragma: no-cache\r\n";
|
||||||
|
requestLine += "Cache-Control: no-cache\r\n";
|
||||||
|
}
|
||||||
if(!request->isKeepAliveEnabled() && !request->isPipeliningEnabled()) {
|
if(!request->isKeepAliveEnabled() && !request->isPipeliningEnabled()) {
|
||||||
requestLine += "Connection: close\r\n";
|
requestLine += "Connection: close\r\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,8 @@ private:
|
||||||
|
|
||||||
SharedHandle<Request> _proxyRequest;
|
SharedHandle<Request> _proxyRequest;
|
||||||
|
|
||||||
|
bool _noCache;
|
||||||
|
|
||||||
std::string getProxyAuthString() const;
|
std::string getProxyAuthString() const;
|
||||||
public:
|
public:
|
||||||
HttpRequest();
|
HttpRequest();
|
||||||
|
@ -243,6 +245,16 @@ public:
|
||||||
{
|
{
|
||||||
return _fileEntry;
|
return _fileEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enableNoCache()
|
||||||
|
{
|
||||||
|
_noCache = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void disableNoCache()
|
||||||
|
{
|
||||||
|
_noCache = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<HttpRequest> HttpRequestHandle;
|
typedef SharedHandle<HttpRequest> HttpRequestHandle;
|
||||||
|
|
|
@ -96,7 +96,11 @@ createHttpRequest(const SharedHandle<Request>& req,
|
||||||
httpRequest->setProxyRequest(proxyRequest);
|
httpRequest->setProxyRequest(proxyRequest);
|
||||||
httpRequest->addAcceptType(rg->getAcceptTypes().begin(),
|
httpRequest->addAcceptType(rg->getAcceptTypes().begin(),
|
||||||
rg->getAcceptTypes().end());
|
rg->getAcceptTypes().end());
|
||||||
|
if(option->getAsBool(PREF_HTTP_NO_CACHE)) {
|
||||||
|
httpRequest->enableNoCache();
|
||||||
|
} else {
|
||||||
|
httpRequest->disableNoCache();
|
||||||
|
}
|
||||||
return httpRequest;
|
return httpRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -707,6 +707,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_HTTP);
|
op->addTag(TAG_HTTP);
|
||||||
handlers.push_back(op);
|
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
|
SharedHandle<OptionHandler> op(new DefaultOptionHandler
|
||||||
(PREF_HTTP_PASSWD,
|
(PREF_HTTP_PASSWD,
|
||||||
|
|
|
@ -89,6 +89,7 @@ const std::set<std::string>& listRequestOptions()
|
||||||
PREF_SPLIT,
|
PREF_SPLIT,
|
||||||
PREF_TIMEOUT,
|
PREF_TIMEOUT,
|
||||||
PREF_HTTP_AUTH_CHALLENGE,
|
PREF_HTTP_AUTH_CHALLENGE,
|
||||||
|
PREF_HTTP_NO_CACHE,
|
||||||
PREF_HTTP_USER,
|
PREF_HTTP_USER,
|
||||||
PREF_HTTP_PASSWD,
|
PREF_HTTP_PASSWD,
|
||||||
PREF_HTTP_PROXY,
|
PREF_HTTP_PROXY,
|
||||||
|
|
|
@ -222,6 +222,8 @@ const std::string PREF_CHECK_CERTIFICATE("check-certificate");
|
||||||
const std::string PREF_USE_HEAD("use-head");
|
const std::string PREF_USE_HEAD("use-head");
|
||||||
// value: true | false
|
// value: true | false
|
||||||
const std::string PREF_HTTP_AUTH_CHALLENGE("http-auth-challenge");
|
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
|
* Proxy related preferences
|
||||||
|
|
|
@ -226,6 +226,8 @@ extern const std::string PREF_CHECK_CERTIFICATE;
|
||||||
extern const std::string PREF_USE_HEAD;
|
extern const std::string PREF_USE_HEAD;
|
||||||
// value: true | false
|
// value: true | false
|
||||||
extern const std::string PREF_HTTP_AUTH_CHALLENGE;
|
extern const std::string PREF_HTTP_AUTH_CHALLENGE;
|
||||||
|
// value: true | false
|
||||||
|
extern const std::string PREF_HTTP_NO_CACHE;
|
||||||
|
|
||||||
/**;
|
/**;
|
||||||
* Proxy related preferences
|
* Proxy related preferences
|
||||||
|
|
|
@ -590,3 +590,9 @@
|
||||||
" .torrent. The directory to be saved is the same\n" \
|
" .torrent. The directory to be saved is the same\n" \
|
||||||
" directory where download file is saved. If the\n" \
|
" directory where download file is saved. If the\n" \
|
||||||
" same file already exists, metadata is not saved.")
|
" 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.")
|
||||||
|
|
Loading…
Reference in New Issue