summaryrefslogtreecommitdiff
path: root/src/HttpRequestCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-07-16 14:13:04 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-07-16 14:13:04 +0000
commit906215317ac105d6dce718d9faf4b045637f923e (patch)
tree1e43095cb3872a252fcadabe340d425f9a71135b /src/HttpRequestCommand.cc
parent55d98cff0b5e19844ff6a70ee3d8d1b061a0e146 (diff)
2010-07-16 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --conditional-get option. Download file only when the local file is older than remote file. This function only works with HTTP(S) downloads only. It does not work if file size is specified in Metalink. It also ignores Content-Disposition header. If a control file exists, this option will be ignored. This function uses If-Modified-Since header to get only newer file conditionally. When getting modification time of local file, it uses user supplied filename(see --out option) or filename part in URI if --out is not specified. * doc/aria2c.1.txt * src/HttpHeader.cc * src/HttpHeader.h * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpResponse.cc * src/HttpResponseCommand.cc * src/OptionHandlerFactory.cc * src/TimeA2.cc * src/TimeA2.h * src/prefs.cc * src/prefs.h * src/usage_text.h * test/HttpResponseTest.cc * test/TimeTest.cc
Diffstat (limited to 'src/HttpRequestCommand.cc')
-rw-r--r--src/HttpRequestCommand.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/HttpRequestCommand.cc b/src/HttpRequestCommand.cc
index e0e39a07..bf6ce6d9 100644
--- a/src/HttpRequestCommand.cc
+++ b/src/HttpRequestCommand.cc
@@ -58,6 +58,8 @@
#include "CheckIntegrityEntry.h"
#include "ServerStatMan.h"
#include "PieceStorage.h"
+#include "DefaultBtProgressInfoFile.h"
+#include "Logger.h"
namespace aria2 {
@@ -144,6 +146,31 @@ bool HttpRequestCommand::executeInternal() {
getDownloadEngine()->getCookieStorage(),
getDownloadEngine()->getAuthConfigFactory(),
proxyRequest_));
+ if(getOption()->getAsBool(PREF_CONDITIONAL_GET) &&
+ (getRequest()->getProtocol() == Request::PROTO_HTTP ||
+ getRequest()->getProtocol() == Request::PROTO_HTTPS)) {
+ if(getFileEntry()->getPath().empty() &&
+ getRequest()->getFile().empty()) {
+ if(getLogger()->debug()) {
+ getLogger()->debug("conditional-get is disabled because file name"
+ "is not available.");
+ }
+ } else {
+ if(getFileEntry()->getPath().empty()) {
+ getFileEntry()->setPath
+ (util::applyDir
+ (getDownloadContext()->getDir(),
+ util::fixTaintedBasename(getRequest()->getFile())));
+ }
+ File ctrlfile(getFileEntry()->getPath()+
+ DefaultBtProgressInfoFile::getSuffix());
+ File file(getFileEntry()->getPath());
+ if(!ctrlfile.exists() && file.exists()) {
+ httpRequest->setIfModifiedSinceHeader
+ (file.getModifiedTime().toHTTPDate());
+ }
+ }
+ }
httpConnection_->sendRequest(httpRequest);
} else {
for(std::vector<SharedHandle<Segment> >::const_iterator itr =