summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-07-01 14:11:04 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-07-01 14:11:04 +0000
commit47309df04d31c1583b435bd81bfd2f350ca2308a (patch)
tree924f297deff936b7fe295335f6688e77a89d7f24 /src
parent1812142da5a8c09c0fdb7e228a611057121e6f53 (diff)
2009-07-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Set referer and method to newly created Request object. * src/CreateRequestCommand.cc * src/FileEntry.cc * src/FileEntry.h
Diffstat (limited to 'src')
-rw-r--r--src/CreateRequestCommand.cc10
-rw-r--r--src/FileEntry.cc7
-rw-r--r--src/FileEntry.h12
3 files changed, 25 insertions, 4 deletions
diff --git a/src/CreateRequestCommand.cc b/src/CreateRequestCommand.cc
index a3ebdfbf..adfd625e 100644
--- a/src/CreateRequestCommand.cc
+++ b/src/CreateRequestCommand.cc
@@ -42,6 +42,8 @@
#include "DownloadEngine.h"
#include "SocketCore.h"
#include "SegmentMan.h"
+#include "prefs.h"
+#include "Option.h"
namespace aria2 {
@@ -65,7 +67,13 @@ bool CreateRequestCommand::executeInternal()
_fileEntry = _requestGroup->getDownloadContext()->findFileEntryByOffset
(_segments.front()->getPositionToWrite());
}
- req = _fileEntry->getRequest(_requestGroup->getURISelector());
+ req = _fileEntry->getRequest(_requestGroup->getURISelector(),
+ getOption()->get(PREF_REFERER),
+ // Don't use HEAD request when file
+ // size is known.
+ _fileEntry->getLength() == 0 &&
+ getOption()->getAsBool(PREF_USE_HEAD)?
+ Request::METHOD_HEAD:Request::METHOD_GET);
if(req.isNull()) {
if(!_requestGroup->getSegmentMan().isNull()) {
_requestGroup->getSegmentMan()->ignoreSegmentFor(_fileEntry);
diff --git a/src/FileEntry.cc b/src/FileEntry.cc
index 28427faf..87203e7c 100644
--- a/src/FileEntry.cc
+++ b/src/FileEntry.cc
@@ -118,7 +118,10 @@ static bool inFlightHost(InputIterator first, InputIterator last,
}
SharedHandle<Request>
-FileEntry::getRequest(const SharedHandle<URISelector>& selector)
+FileEntry::getRequest
+(const SharedHandle<URISelector>& selector,
+ const std::string& referer,
+ const std::string& method)
{
SharedHandle<Request> req;
if(_requestPool.empty()) {
@@ -138,6 +141,8 @@ FileEntry::getRequest(const SharedHandle<URISelector>& selector)
continue;
}
}
+ req->setReferer(referer);
+ req->setMethod(method);
_spentUris.push_back(uri);
_inFlightRequests.push_back(req);
break;
diff --git a/src/FileEntry.h b/src/FileEntry.h
index f0b55700..e98dc9e4 100644
--- a/src/FileEntry.h
+++ b/src/FileEntry.h
@@ -46,6 +46,7 @@
#include "Request.h"
#include "URIResult.h"
#include "DownloadResultCode.h"
+#include "A2STR.h"
namespace aria2 {
@@ -163,8 +164,15 @@ public:
// If pooled Request object is available, one of them is removed
// from the pool and returned. If pool is empty, then select URI
// using selectUri(selector) and construct Request object using it
- // and return the Request object.
- SharedHandle<Request> getRequest(const SharedHandle<URISelector>& selector);
+ // and return the Request object. If referer is given, it is set to
+ // newly created Request. If Request object is retrieved from the
+ // pool, referer is ignored. If method is given, it is set to newly
+ // created Request. If Request object is retrieved from the pool,
+ // method is ignored.
+ SharedHandle<Request> getRequest
+ (const SharedHandle<URISelector>& selector,
+ const std::string& referer = A2STR::NIL,
+ const std::string& method = Request::METHOD_GET);
// Finds pooled Request object which is faster than passed one,
// comparing their PeerStat objects. If such Request is found, it is