mirror of https://github.com/aria2/aria2
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.hpull/1/head
parent
1812142da5
commit
47309df04d
|
@ -1,3 +1,10 @@
|
||||||
|
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
|
||||||
|
|
||||||
2009-07-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-07-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Removed ctor of AbstractCommand which doesn't take FileEntry.
|
Removed ctor of AbstractCommand which doesn't take FileEntry.
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "SocketCore.h"
|
#include "SocketCore.h"
|
||||||
#include "SegmentMan.h"
|
#include "SegmentMan.h"
|
||||||
|
#include "prefs.h"
|
||||||
|
#include "Option.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -65,7 +67,13 @@ bool CreateRequestCommand::executeInternal()
|
||||||
_fileEntry = _requestGroup->getDownloadContext()->findFileEntryByOffset
|
_fileEntry = _requestGroup->getDownloadContext()->findFileEntryByOffset
|
||||||
(_segments.front()->getPositionToWrite());
|
(_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(req.isNull()) {
|
||||||
if(!_requestGroup->getSegmentMan().isNull()) {
|
if(!_requestGroup->getSegmentMan().isNull()) {
|
||||||
_requestGroup->getSegmentMan()->ignoreSegmentFor(_fileEntry);
|
_requestGroup->getSegmentMan()->ignoreSegmentFor(_fileEntry);
|
||||||
|
|
|
@ -118,7 +118,10 @@ static bool inFlightHost(InputIterator first, InputIterator last,
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<Request>
|
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;
|
SharedHandle<Request> req;
|
||||||
if(_requestPool.empty()) {
|
if(_requestPool.empty()) {
|
||||||
|
@ -138,6 +141,8 @@ FileEntry::getRequest(const SharedHandle<URISelector>& selector)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
req->setReferer(referer);
|
||||||
|
req->setMethod(method);
|
||||||
_spentUris.push_back(uri);
|
_spentUris.push_back(uri);
|
||||||
_inFlightRequests.push_back(req);
|
_inFlightRequests.push_back(req);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "URIResult.h"
|
#include "URIResult.h"
|
||||||
#include "DownloadResultCode.h"
|
#include "DownloadResultCode.h"
|
||||||
|
#include "A2STR.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -163,8 +164,15 @@ public:
|
||||||
// If pooled Request object is available, one of them is removed
|
// If pooled Request object is available, one of them is removed
|
||||||
// from the pool and returned. If pool is empty, then select URI
|
// from the pool and returned. If pool is empty, then select URI
|
||||||
// using selectUri(selector) and construct Request object using it
|
// using selectUri(selector) and construct Request object using it
|
||||||
// and return the Request object.
|
// and return the Request object. If referer is given, it is set to
|
||||||
SharedHandle<Request> getRequest(const SharedHandle<URISelector>& selector);
|
// 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,
|
// Finds pooled Request object which is faster than passed one,
|
||||||
// comparing their PeerStat objects. If such Request is found, it is
|
// comparing their PeerStat objects. If such Request is found, it is
|
||||||
|
|
Loading…
Reference in New Issue