#include <Downloader.h>


Classes | |
class | CbDialer |
Callback data to use with Downloader callbacks. More... | |
Public Types | |
typedef CbcPointer< AsyncJob > | Pointer |
Public Member Functions | |
Downloader (SBuf &url, AsyncCall::Pointer &aCallback, const XactionInitiator initiator, unsigned int level=0) | |
virtual | ~Downloader () |
virtual void | swanSong () |
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... | |
virtual void * | toCbdata ()=0 |
Static Public Member Functions | |
static Pointer | Start (AsyncJob *job) |
starts a freshly created job (i.e., makes the job asynchronous) More... | |
Protected Member Functions | |
virtual bool | doneAll () const |
whether positive goal has been reached More... | |
virtual void | start () |
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... | |
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... | |
const InstanceId< AsyncJob > | id |
job identifier More... | |
Private Member Functions | |
CBDATA_CLASS (Downloader) | |
bool | buildRequest () |
Initializes and starts the HTTP GET request to the remote server. More... | |
void | callBack (Http::StatusCode const status) |
Private Attributes | |
SBuf | url_ |
the url to download More... | |
AsyncCall::Pointer | callback_ |
callback to call when download finishes More... | |
SBuf | object_ |
the object body data More... | |
const unsigned int | level_ |
XactionInitiator | initiator_ |
The initiator of the download request. 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 29 of file Downloader.h.
Member Typedef Documentation
◆ Pointer
|
inherited |
Definition at line 34 of file AsyncJob.h.
Constructor & Destructor Documentation
◆ Downloader()
Downloader::Downloader | ( | SBuf & | url, |
AsyncCall::Pointer & | aCallback, | ||
const XactionInitiator | initiator, | ||
unsigned int | level = 0 |
||
) |
Definition at line 66 of file Downloader.cc.
◆ ~Downloader()
|
virtual |
Definition at line 75 of file Downloader.cc.
References debugs.
Member Function Documentation
◆ buildRequest()
|
private |
Definition at line 127 of file Downloader.cc.
References SBuf::c_str(), ClientHttpRequest::calloutContext, ClientHttpRequest::client_stream, clientGetMoreData, clientReplyDetach, clientReplyStatus, clientStreamInit(), context_, StoreIOBuffer::data, Http::DATE, debugs, ClientHttpRequest::doCallouts(), downloaderDetach(), downloaderRecipient(), HttpRequest::FromUrl(), RefCount< C >::getRaw(), Http::HOST, HTTP_REQBUF_SZ, initiator_, ClientHttpRequest::initRequest(), StoreIOBuffer::length, method, _request::method, Http::METHOD_GET, Http::ProtocolVersion(), ClientHttpRequest::req_sz, request(), DownloaderContext::requestBuffer, squid_curtime, ClientHttpRequest::uri, _request::url, url_, and xstrdup.
Referenced by start().
◆ callBack()
|
private |
Schedules for execution the "callback" with parameters the status and object.
Definition at line 252 of file Downloader.cc.
References callback_, CallJobHere, downloadFinished(), AsyncCall::getDialer(), Must, Downloader::CbDialer::object, object_, ScheduleCallHere, Http::scOkay, and Downloader::CbDialer::status.
Referenced by handleReply(), and start().
◆ callEnd()
|
virtualinherited |
called right after the called job method
Reimplemented in Adaptation::Icap::Xaction.
Definition at line 136 of file AsyncJob.cc.
References AsyncCall::debugLevel, debugs, AsyncCall::debugSection, AsyncJob::done(), HERE(), AsyncJob::inCall, NULL, AsyncJob::status(), AsyncJob::swanSong(), and AsyncJob::typeName.
Referenced by Adaptation::Icap::Xaction::callEnd(), and AsyncJob::deleteThis().
◆ callException()
|
virtualinherited |
Reimplemented in ClientHttpRequest, Ftp::Server, Ipc::Inquirer, Ipc::Forwarder, Adaptation::Icap::Xaction, Adaptation::Icap::ServiceRep, Adaptation::Icap::ModXact, and ConnStateData.
Definition at line 127 of file AsyncJob.cc.
References cbdataReferenceValid(), debugs, Must, AsyncJob::mustStop(), and CbdataParent::toCbdata().
Referenced by ConnStateData::callException(), Adaptation::Icap::Xaction::callException(), Ipc::Forwarder::callException(), Ipc::Inquirer::callException(), and Ftp::Server::callException().
◆ callStart()
|
inherited |
called just before the called method
Definition at line 114 of file AsyncJob.cc.
References cbdataReferenceValid(), AsyncCall::debugLevel, debugs, AsyncCall::debugSection, AsyncJob::inCall, Must, AsyncJob::status(), CbdataParent::toCbdata(), and AsyncJob::typeName.
◆ canBeCalled()
|
inherited |
Definition at line 101 of file AsyncJob.cc.
References AsyncCall::cancel(), debugs, HERE(), AsyncJob::inCall, and NULL.
◆ CBDATA_CLASS()
|
private |
◆ deleteThis()
|
protectedinherited |
Definition at line 49 of file AsyncJob.cc.
References asyncCall(), AsyncJob::callEnd(), debugs, AsyncJob::inCall, JobMemFun(), Must, NULL, AsyncJob::stopReason, and AsyncJob::typeName.
Referenced by ConnStateData::connStateClosed().
◆ done()
|
protectedinherited |
Definition at line 90 of file AsyncJob.cc.
References AsyncJob::doneAll(), NULL, and AsyncJob::stopReason.
Referenced by AsyncJob::callEnd(), HappyConnOpener::checkForNewConnection(), and downloadFinished().
◆ doneAll()
|
protectedvirtual |
Reimplemented from AsyncJob.
Definition at line 91 of file Downloader.cc.
References callback_, AsyncCall::canceled(), and AsyncJob::doneAll().
◆ downloadFinished()
void Downloader::downloadFinished | ( | ) |
Definition at line 243 of file Downloader.cc.
References debugs, AsyncJob::done(), and Must.
Referenced by callBack().
◆ handleReply()
void Downloader::handleReply | ( | clientStreamNode * | node, |
ClientHttpRequest * | http, | ||
HttpReply * | reply, | ||
StoreIOBuffer | receivedData | ||
) |
Definition at line 184 of file Downloader.cc.
References SBuf::append(), assert, callBack(), clientStreamRead(), clientStreamStatus(), Http::Message::content_length, context_, StoreIOBuffer::data, debugs, StoreIOBuffer::error, fatal(), StoreIOBuffer::flags, HTTP_REQBUF_SZ, SBuf::length(), StoreIOBuffer::length, MaxObjectSize, SBuf::maxSize, object_, ClientHttpRequest::Out::offset, StoreIOBuffer::offset, ClientHttpRequest::out, DownloaderContext::requestBuffer, Http::scInternalServerError, Http::scOkay, ClientHttpRequest::Out::size, STREAM_COMPLETE, STREAM_FAILED, STREAM_NONE, and STREAM_UNPLANNED_COMPLETE.
Referenced by downloaderRecipient().
◆ mustStop()
|
protectedinherited |
Definition at line 69 of file AsyncJob.cc.
References debugs, AsyncJob::inCall, Must, NULL, AsyncJob::stopReason, and AsyncJob::typeName.
Referenced by HttpStateData::abortAll(), AsyncJob::callException(), HttpStateData::continueAfterParsingHeader(), HttpStateData::drop1xx(), HttpStateData::handleMoreRequestBodyAvailable(), HttpStateData::httpStateConnClosed(), HttpStateData::httpTimeout(), Comm::ConnOpener::noteAbort(), HttpStateData::proceedAfter1xx(), ConnStateData::proxyProtocolError(), HttpStateData::readReply(), HttpStateData::start(), and HttpStateData::wroteLast().
◆ nestedLevel()
|
inline |
Definition at line 57 of file Downloader.h.
References level_.
Referenced by Security::PeerConnector::checkForMissingCertificates(), and Security::PeerConnector::startCertDownloading().
◆ start()
|
protectedvirtual |
Reimplemented from AsyncJob.
Definition at line 177 of file Downloader.cc.
References buildRequest(), callBack(), and Http::scInternalServerError.
◆ Start()
|
staticinherited |
Definition at line 23 of file AsyncJob.cc.
References CallJobHere, and AsyncJob::start().
Referenced by Ftp::Server::AcceptCtrlConnection(), Ftp::Server::checkDataConnPre(), clientListenerConnectionOpened(), Ftp::Client::connectDataChannel(), FwdState::connectStart(), Adaptation::Icap::Xaction::dnsLookupDone(), Log::TcpLogger::doConnect(), FwdState::establishTunnelThruProxy(), TunnelStateData::establishTunnelThruProxy(), Ipc::Coordinator::handleCacheMgrRequest(), PeerPoolMgr::handleOpenedConnection(), Ipc::Coordinator::handleSnmpRequest(), httpAccept(), httpsAccept(), httpStart(), idnsInitVC(), Ftp::Gateway::listenForDataChannel(), Ftp::Server::listenForDataConnection(), Adaptation::Icap::Xaction::noteCommConnected(), Log::TcpLogger::Open(), HappyConnOpener::openFreshConnection(), PeerPoolMgr::openNewConnection(), peerProbeConnect(), Mgr::FunAction::respond(), Mgr::InfoAction::respond(), FwdState::secureConnectionToPeer(), TunnelStateData::secureConnectionToPeer(), Ipc::SendMessage(), Mgr::Inquirer::sendResponse(), snmpConstructReponse(), SquidMain(), CacheManager::start(), Ident::Start(), Adaptation::AccessCheck::Start(), Rock::Rebuild::Start(), Security::PeerConnector::startCertDownloading(), TunnelStateData::startConnecting(), Ftp::StartGateway(), Ftp::StartRelay(), PeerPoolMgrsRr::syncConfig(), and Rock::SwapDir::updateHeaders().
◆ status()
|
protectedvirtualinherited |
for debugging, starts with space
Reimplemented in HappyConnOpener, Security::PeerConnector, Ipc::Inquirer, Comm::TcpAcceptor, Http::Tunneler, Adaptation::Initiate, Adaptation::Icap::Xaction, Adaptation::Icap::ServiceRep, and Adaptation::Ecap::XactionRep.
Definition at line 159 of file AsyncJob.cc.
References buf, NULL, and AsyncJob::stopReason.
Referenced by AsyncJob::callEnd(), AsyncJob::callStart(), Adaptation::Initiate::status(), and Comm::TcpAcceptor::status().
◆ swanSong()
|
virtual |
Reimplemented from AsyncJob.
Definition at line 81 of file Downloader.cc.
References context_, debugs, and DownloaderContext::finished().
◆ toCbdata()
|
pure virtualinherited |
Implemented in HttpStateData, ClientHttpRequest, and BodySink.
Referenced by AsyncJob::callException(), and AsyncJob::callStart().
Member Data Documentation
◆ callback_
|
private |
Definition at line 76 of file Downloader.h.
Referenced by callBack(), and doneAll().
◆ context_
|
private |
Definition at line 83 of file Downloader.h.
Referenced by buildRequest(), handleReply(), and swanSong().
◆ id
|
protectedinherited |
Definition at line 72 of file AsyncJob.h.
◆ inCall
|
protectedinherited |
Definition at line 71 of file AsyncJob.h.
Referenced by AsyncJob::callEnd(), AsyncJob::callStart(), AsyncJob::canBeCalled(), AsyncJob::deleteThis(), and AsyncJob::mustStop().
◆ initiator_
|
private |
Definition at line 80 of file Downloader.h.
Referenced by buildRequest().
◆ level_
|
private |
holds the nested downloads level
Definition at line 78 of file Downloader.h.
Referenced by nestedLevel().
◆ MaxObjectSize
|
staticprivate |
Definition at line 73 of file Downloader.h.
Referenced by handleReply().
◆ object_
|
private |
Definition at line 77 of file Downloader.h.
Referenced by callBack(), and handleReply().
◆ stopReason
|
protectedinherited |
Definition at line 69 of file AsyncJob.h.
Referenced by AsyncJob::deleteThis(), AsyncJob::done(), AsyncJob::mustStop(), AsyncJob::status(), and HappyConnOpener::status().
◆ typeName
|
protectedinherited |
Definition at line 70 of file AsyncJob.h.
Referenced by AsyncJob::AsyncJob(), Adaptation::Icap::Xaction::Xaction(), AsyncJob::~AsyncJob(), AsyncJob::callEnd(), AsyncJob::callStart(), AsyncJob::deleteThis(), and AsyncJob::mustStop().
◆ url_
|
private |
Definition at line 75 of file Downloader.h.
Referenced by buildRequest().
The documentation for this class was generated from the following files:
- src/Downloader.h
- src/Downloader.cc