#include <Downloader.h>

Inheritance diagram for Downloader:
Collaboration diagram for Downloader:

Public Types

using Answer = DownloaderAnswer
 
typedef CbcPointer< AsyncJobPointer
 

Public Member Functions

 Downloader (const SBuf &url, const AsyncCallback< Answer > &, const MasterXactionPointer &, unsigned int level=0)
 
 ~Downloader () override
 
void swanSong () override
 
void downloadFinished ()
 delays destruction to protect doCallouts() More...
 
unsigned int nestedLevel () const
 The nested level of Downloader object (downloads inside downloads). More...
 
void handleReply (clientStreamNode *, ClientHttpRequest *, HttpReply *, StoreIOBuffer)
 
bool canBeCalled (AsyncCall &call) const
 whether we can be called More...
 
void callStart (AsyncCall &call)
 
virtual void callEnd ()
 called right after the called job method More...
 
virtual void callException (const std::exception &e)
 called when the job throws during an async call More...
 
void handleStopRequest ()
 process external request to terminate now (i.e. during this async call) More...
 
virtual void * toCbdata ()=0
 

Static Public Member Functions

static void Start (const Pointer &job)
 
static void RegisterWithCacheManager ()
 

Public Attributes

const InstanceId< AsyncJobid
 job identifier More...
 

Protected Member Functions

bool doneAll () const override
 whether positive goal has been reached More...
 
void start () override
 called by AsyncStart; do not call directly More...
 
void deleteThis (const char *aReason)
 
void mustStop (const char *aReason)
 
bool done () const
 the job is destroyed in callEnd() when done() More...
 
virtual const char * status () const
 internal cleanup; do not call directly More...
 

Static Protected Member Functions

static void ReportAllJobs (StoreEntry *)
 writes a cache manager report about all jobs existing in this worker More...
 

Protected Attributes

const char * stopReason
 reason for forcing done() to be true More...
 
const char * typeName
 kid (leaf) class name, for debugging More...
 
AsyncCall::Pointer inCall
 the asynchronous call being handled, if any More...
 
bool started_ = false
 Start() has finished successfully. More...
 
bool swanSang_ = false
 swanSong() was called More...
 

Private Member Functions

 CBDATA_CHILD (Downloader)
 
bool buildRequest ()
 Initializes and starts the HTTP GET request to the remote server. More...
 
void callBack (Http::StatusCode const status)
 
virtual void finalizedInCbdataChild ()=0
 hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE() More...
 

Private Attributes

SBuf url_
 the url to download More...
 
AsyncCallback< Answercallback_
 answer destination More...
 
SBuf object_
 the object body data More...
 
const unsigned int level_
 holds the nested downloads level More...
 
MasterXactionPointer masterXaction_
 download transaction context More...
 
DownloaderContextPointer context_
 Pointer to an object that stores the clientStream required info. More...
 

Static Private Attributes

static const size_t MaxObjectSize = 1*1024*1024
 The maximum allowed object size. More...
 

Detailed Description

The Downloader class fetches SBuf-storable things for other Squid components/transactions using internal requests. For example, it is used to fetch missing intermediate certificates when validating origin server certificate chains.

Definition at line 45 of file Downloader.h.

Member Typedef Documentation

◆ Answer

Definition at line 49 of file Downloader.h.

◆ Pointer

Definition at line 34 of file AsyncJob.h.

Constructor & Destructor Documentation

◆ Downloader()

Downloader::Downloader ( const SBuf url,
const AsyncCallback< Answer > &  cb,
const MasterXactionPointer mx,
unsigned int  level = 0 
)

Definition at line 70 of file Downloader.cc.

◆ ~Downloader()

Downloader::~Downloader ( )
override

Definition at line 79 of file Downloader.cc.

References debugs.

Member Function Documentation

◆ buildRequest()

◆ callBack()

void Downloader::callBack ( Http::StatusCode const  statusCode)
private

Schedules for execution the "callback" with parameters the status and object.

Definition at line 259 of file Downloader.cc.

References assert, callback_, CallJobHere, downloadFinished(), object_, ScheduleCallHere, and Http::scOkay.

Referenced by handleReply(), start(), and swanSong().

◆ callEnd()

void AsyncJob::callEnd ( )
virtualinherited

◆ callException()

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)
inherited

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const
inherited

Definition at line 117 of file AsyncJob.cc.

References AsyncCall::cancel(), debugs, and AsyncJob::inCall.

◆ CBDATA_CHILD()

Downloader::CBDATA_CHILD ( Downloader  )
private

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)
protectedinherited

◆ done()

bool AsyncJob::done ( ) const
protectedinherited

◆ doneAll()

bool Downloader::doneAll ( ) const
overrideprotectedvirtual

Reimplemented from AsyncJob.

Definition at line 99 of file Downloader.cc.

References callback_, and AsyncJob::doneAll().

◆ downloadFinished()

void Downloader::downloadFinished ( )

Definition at line 250 of file Downloader.cc.

References debugs, AsyncJob::done(), and Must.

Referenced by callBack().

◆ finalizedInCbdataChild()

virtual void CbdataParent::finalizedInCbdataChild ( )
privatepure virtualinherited

◆ handleReply()

◆ handleStopRequest()

void AsyncJob::handleStopRequest ( )
inlineinherited

Definition at line 73 of file AsyncJob.h.

References AsyncJob::mustStop().

◆ mustStop()

◆ nestedLevel()

unsigned int Downloader::nestedLevel ( ) const
inline

Definition at line 59 of file Downloader.h.

References level_.

◆ RegisterWithCacheManager()

void AsyncJob::RegisterWithCacheManager ( )
staticinherited

Definition at line 215 of file AsyncJob.cc.

References Mgr::RegisterAction(), and AsyncJob::ReportAllJobs().

Referenced by mainInitialize().

◆ ReportAllJobs()

void AsyncJob::ReportAllJobs ( StoreEntry e)
staticprotectedinherited

Definition at line 198 of file AsyncJob.cc.

References AllJobs().

Referenced by AsyncJob::RegisterWithCacheManager().

◆ start()

void Downloader::start ( )
overrideprotectedvirtual

Reimplemented from AsyncJob.

Definition at line 184 of file Downloader.cc.

References buildRequest(), callBack(), and Http::scInternalServerError.

◆ Start()

◆ status()

◆ swanSong()

void Downloader::swanSong ( )
overridevirtual

Reimplemented from AsyncJob.

Definition at line 85 of file Downloader.cc.

References callBack(), callback_, context_, debugs, DownloaderContext::finished(), and Http::scInternalServerError.

◆ toCbdata()

virtual void * CbdataParent::toCbdata ( )
pure virtualinherited

Member Data Documentation

◆ callback_

AsyncCallback<Answer> Downloader::callback_
private

Definition at line 80 of file Downloader.h.

Referenced by callBack(), doneAll(), and swanSong().

◆ context_

DownloaderContextPointer Downloader::context_
private

Definition at line 87 of file Downloader.h.

Referenced by buildRequest(), handleReply(), and swanSong().

◆ id

const InstanceId<AsyncJob> AsyncJob::id
inherited

Definition at line 75 of file AsyncJob.h.

◆ inCall

AsyncCall::Pointer AsyncJob::inCall
protectedinherited

◆ level_

const unsigned int Downloader::level_
private

Definition at line 83 of file Downloader.h.

Referenced by nestedLevel().

◆ masterXaction_

MasterXactionPointer Downloader::masterXaction_
private

Definition at line 84 of file Downloader.h.

Referenced by buildRequest().

◆ MaxObjectSize

const size_t Downloader::MaxObjectSize = 1*1024*1024
staticprivate

Definition at line 75 of file Downloader.h.

Referenced by handleReply().

◆ object_

SBuf Downloader::object_
private

Definition at line 82 of file Downloader.h.

Referenced by callBack(), and handleReply().

◆ started_

bool AsyncJob::started_ = false
protectedinherited

Definition at line 88 of file AsyncJob.h.

Referenced by AsyncJob::~AsyncJob(), AsyncJob::callEnd(), and AsyncJob::Start().

◆ stopReason

const char* AsyncJob::stopReason
protectedinherited

◆ swanSang_

bool AsyncJob::swanSang_ = false
protectedinherited

Definition at line 89 of file AsyncJob.h.

Referenced by AsyncJob::~AsyncJob(), and AsyncJob::callEnd().

◆ typeName

◆ url_

SBuf Downloader::url_
private

Definition at line 77 of file Downloader.h.

Referenced by buildRequest().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors