#include <Client.h>

Inheritance diagram for Client:
Collaboration diagram for Client:

Public Types

typedef CbcPointer< AsyncJobPointer
 
typedef CbcPointer< BodyProducerPointer
 
typedef CbcPointer< BodyConsumerPointer
 

Public Member Functions

 Client (FwdState *)
 
virtual ~Client ()
 
virtual const Comm::ConnectionPointerdataConnection () const =0
 
virtual void noteMoreBodyDataAvailable (BodyPipe::Pointer)
 
virtual void noteBodyProductionEnded (BodyPipe::Pointer)
 
virtual void noteBodyProducerAborted (BodyPipe::Pointer)
 
virtual void maybeReadVirginBody ()=0
 read response data from the network More...
 
virtual void abortAll (const char *reason)=0
 abnormal transaction termination; reason is for debugging only More...
 
virtual bool abortOnData (const char *reason)
 
virtual HttpRequestPointer originalRequest ()
 a hack to reach HttpStateData::orignal_request More...
 
virtual void noteAdaptationAnswer (const Adaptation::Answer &answer)
 
virtual void noteAdaptationAclCheckDone (Adaptation::ServiceGroupPointer group)
 
virtual void noteMoreBodySpaceAvailable (BodyPipe::Pointer)
 
virtual void noteBodyConsumerAborted (BodyPipe::Pointer)
 
virtual bool getMoreRequestBody (MemBuf &buf)
 either fill buf with available [encoded] request body bytes or return false More...
 
virtual void processReplyBody ()=0
 
virtual void swanSong ()
 
virtual bool doneAll () const
 whether positive goal has been reached More...
 
void serverComplete ()
 
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...
 

Public Attributes

StoreEntryentry = nullptr
 
FwdState::Pointer fwd
 
HttpRequestPointer request
 

Protected Member Functions

virtual void haveParsedReplyHeaders ()
 called when we have final (possibly adapted) reply headers; kids extend More...
 
virtual void completeForwarding ()
 
bool startRequestBodyFlow ()
 
void handleMoreRequestBodyAvailable ()
 
void handleRequestBodyProductionEnded ()
 
virtual void handleRequestBodyProducerAborted ()=0
 
void sendMoreRequestBody ()
 
virtual void sentRequestBody (const CommIoCbParams &io)=0
 
virtual void doneSendingRequestBody ()=0
 
virtual void closeServer ()=0
 
virtual bool doneWithServer () const =0
 
virtual bool mayReadVirginReplyBody () const =0
 whether we may receive more virgin response body bytes More...
 
bool abortOnBadEntry (const char *abortReason)
 Entry-dependent callbacks use this check to quit if the entry went bad. More...
 
bool blockCaching ()
 whether to prevent caching of an otherwise cachable response More...
 
void startAdaptation (const Adaptation::ServiceGroupPointer &group, HttpRequest *cause)
 Initiate an asynchronous adaptation transaction which will call us back. More...
 
void adaptVirginReplyBody (const char *buf, ssize_t len)
 
void cleanAdaptation ()
 
virtual bool doneWithAdaptation () const
 
void handleMoreAdaptedBodyAvailable ()
 
void handleAdaptedBodyProductionEnded ()
 
void handleAdaptedBodyProducerAborted ()
 
void handleAdaptedHeader (Http::Message *msg)
 
void handleAdaptationCompleted ()
 
void handleAdaptationBlocked (const Adaptation::Answer &answer)
 
void handleAdaptationAborted (bool bypassable=false)
 
bool handledEarlyAdaptationAbort ()
 
void resumeBodyStorage ()
 called by StoreEntry when it has more buffer space available More...
 
void endAdaptedBodyConsumption ()
 called when the entire adapted response body is consumed More...
 
const HttpReplyvirginReply () const
 
HttpReplyvirginReply ()
 
HttpReplysetVirginReply (HttpReply *r)
 
HttpReplyfinalReply ()
 
HttpReplysetFinalReply (HttpReply *r)
 
void adaptOrFinalizeReply ()
 
void addVirginReplyBody (const char *buf, ssize_t len)
 
void storeReplyBody (const char *buf, ssize_t len)
 
size_t replyBodySpace (const MemBuf &readBuf, const size_t minSpace) const
 
size_t calcBufferSpaceToReserve (const size_t space, const size_t wantSpace) const
 determine how much space the buffer needs to reserve More...
 
void adjustBodyBytesRead (const int64_t delta)
 initializes bodyBytesRead stats if needed and applies delta More...
 
CbcPointer< Initiate > initiateAdaptation (Initiate *x)
 < starts freshly created initiate and returns a safe pointer to it More...
 
void clearAdaptation (CbcPointer< Initiate > &x)
 clears the pointer (does not call announceInitiatorAbort) More...
 
void announceInitiatorAbort (CbcPointer< Initiate > &x)
 inform the transaction about abnormal termination and clear the pointer More...
 
bool initiated (const CbcPointer< AsyncJob > &job) const
 Must(initiated(initiate)) instead of Must(initiate.set()), for clarity. More...
 
void deleteThis (const char *aReason)
 
void mustStop (const char *aReason)
 
bool done () const
 the job is destroyed in callEnd() when done() More...
 
virtual void start ()
 called by AsyncStart; do not call directly More...
 
virtual const char * status () const
 internal cleanup; do not call directly More...
 
void stopProducingFor (RefCount< BodyPipe > &, bool atEof)
 
void stopConsumingFrom (RefCount< BodyPipe > &)
 

Protected Attributes

int64_t currentOffset = 0
 
MemBufresponseBodyBuffer = nullptr
 
BodyPipe::Pointer requestBodySource
 
AsyncCall::Pointer requestSender
 
BodyPipe::Pointer virginBodyDestination
 
CbcPointer< Adaptation::InitiateadaptedHeadSource
 
BodyPipe::Pointer adaptedBodySource
 
bool adaptationAccessCheckPending = false
 
bool startedAdaptation = false
 
bool receivedWholeRequestBody = false
 handleRequestBodyProductionEnded called More...
 
const char * doneWithFwd = nullptr
 
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< AsyncJobid
 job identifier More...
 

Private Member Functions

void serverComplete2 ()
 
void sendBodyIsTooLargeError ()
 
void maybePurgeOthers ()
 

Private Attributes

bool completed = false
 
HttpReplytheVirginReply = nullptr
 
HttpReplytheFinalReply = nullptr
 

Detailed Description

Client is a common base for classes such as HttpStateData and FtpStateData. All such classes must be able to consume request bodies from a BodyPipe or ICAP producer, adapt virgin responses using ICAP, and provide a consumer with responses.

Definition at line 29 of file Client.h.

Member Typedef Documentation

◆ Pointer [1/3]

Definition at line 25 of file BodyPipe.h.

◆ Pointer [2/3]

Definition at line 34 of file AsyncJob.h.

◆ Pointer [3/3]

Definition at line 45 of file BodyPipe.h.

Constructor & Destructor Documentation

◆ Client()

Client::Client ( FwdState theFwdState)

Definition at line 39 of file Client.cc.

References FwdState::entry, entry, fwd, and StoreEntry::lock().

◆ ~Client()

Client::~Client ( )
virtual

Member Function Documentation

◆ abortAll()

virtual void Client::abortAll ( const char *  reason)
pure virtual

◆ abortOnBadEntry()

◆ abortOnData()

bool Client::abortOnData ( const char *  reason)
virtual

abnormal data transfer termination

Return values
truethe transaction will be terminated (abortAll called)
falsethe transaction will survive

Reimplemented in Ftp::Relay.

Definition at line 287 of file Client.cc.

References abortAll().

Referenced by abortOnBadEntry(), Ftp::Client::dataRead(), handleAdaptationBlocked(), Ftp::Client::readControlReply(), sendBodyIsTooLargeError(), and sentRequestBody().

◆ adaptOrFinalizeReply()

◆ adaptVirginReplyBody()

void Client::adaptVirginReplyBody ( const char *  buf,
ssize_t  len 
)
protected

◆ addVirginReplyBody()

◆ adjustBodyBytesRead()

void Client::adjustBodyBytesRead ( const int64_t  delta)
protected

Definition at line 962 of file Client.cc.

References HierarchyLogEntry::bodyBytesRead, HttpRequest::hier, Must, and originalRequest().

Referenced by addVirginReplyBody().

◆ announceInitiatorAbort()

◆ blockCaching()

◆ calcBufferSpaceToReserve()

size_t Client::calcBufferSpaceToReserve ( const size_t  space,
const size_t  wantSpace 
) const
protected

◆ callEnd()

void AsyncJob::callEnd ( )
virtualinherited

◆ callException()

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)
inherited

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const
inherited

Definition at line 101 of file AsyncJob.cc.

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

Referenced by AsyncJob::swanSong().

◆ cleanAdaptation()

◆ clearAdaptation()

◆ closeServer()

virtual void Client::closeServer ( )
protectedpure virtual

Use this to end communication with the server. The call cancels our closure handler and tells FwdState to forget about the connection.

Implemented in Ftp::Client, and HttpStateData.

Referenced by handleAdaptationCompleted(), serverComplete(), and swanSong().

◆ completeForwarding()

void Client::completeForwarding ( )
protectedvirtual

default calls fwd->complete()

Reimplemented in Ftp::Gateway, and Ftp::Relay.

Definition at line 206 of file Client.cc.

References assert, FwdState::complete(), debugs, doneWithFwd, fwd, HERE(), and NULL.

Referenced by Ftp::Relay::completeForwarding(), Ftp::Gateway::completeForwarding(), handleAdaptationCompleted(), and serverComplete2().

◆ dataConnection()

virtual const Comm::ConnectionPointer& Client::dataConnection ( ) const
pure virtual
Returns
primary or "request data connection"

Implemented in Ftp::Client, and HttpStateData.

Referenced by sendMoreRequestBody().

◆ deleteThis()

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

◆ done()

◆ doneAll()

bool Client::doneAll ( ) const
virtual

Reimplemented from AsyncJob.

Definition at line 193 of file Client.cc.

References AsyncJob::doneAll(), doneWithAdaptation(), and doneWithServer().

◆ doneSendingRequestBody()

void Client::doneSendingRequestBody ( )
protectedpure virtual

◆ doneWithAdaptation()

bool Client::doneWithAdaptation ( ) const
protectedvirtual

◆ doneWithServer()

virtual bool Client::doneWithServer ( ) const
protectedpure virtual

did we end communication?

Implemented in Ftp::Client, and HttpStateData.

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

◆ endAdaptedBodyConsumption()

void Client::endAdaptedBodyConsumption ( )
protected

◆ finalReply()

HttpReply * Client::finalReply ( )
protected

Definition at line 128 of file Client.cc.

References assert, and theFinalReply.

Referenced by HttpStateData::haveParsedReplyHeaders(), and HttpStateData::reusableReply().

◆ getMoreRequestBody()

bool Client::getMoreRequestBody ( MemBuf buf)
virtual

Reimplemented in HttpStateData.

Definition at line 414 of file Client.cc.

References BodyPipe::getMoreData(), Must, NULL, and requestBodySource.

Referenced by HttpStateData::getMoreRequestBody(), and sendMoreRequestBody().

◆ handleAdaptationAborted()

void Client::handleAdaptationAborted ( bool  bypassable = false)
protected

◆ handleAdaptationBlocked()

◆ handleAdaptationCompleted()

void Client::handleAdaptationCompleted ( )
protected

◆ handleAdaptedBodyProducerAborted()

◆ handleAdaptedBodyProductionEnded()

void Client::handleAdaptedBodyProductionEnded ( )
protected

◆ handleAdaptedHeader()

◆ handledEarlyAdaptationAbort()

bool Client::handledEarlyAdaptationAbort ( )
protected

If the store entry is still empty, fully handles adaptation abort, returning true. Otherwise just updates the request error detail and returns false.

Definition at line 855 of file Client.cc.

References abortAll(), FwdState::al, debugs, HttpRequest::detailError(), ErrorState::detailError(), FwdState::dontRetry(), entry, ERR_DETAIL_ICAP_RESPMOD_EARLY, ERR_DETAIL_ICAP_RESPMOD_LATE, ERR_ICAP_FAILURE, FwdState::fail(), fwd, RefCount< C >::getRaw(), StoreEntry::isEmpty(), request, and Http::scInternalServerError.

Referenced by handleAdaptationAborted(), and handleAdaptedBodyProducerAborted().

◆ handleMoreAdaptedBodyAvailable()

◆ handleMoreRequestBodyAvailable()

void Client::handleMoreRequestBodyAvailable ( )
protected

Definition at line 295 of file Client.cc.

References debugs, HERE(), requestSender, and sendMoreRequestBody().

Referenced by noteMoreBodyDataAvailable().

◆ handleRequestBodyProducerAborted()

◆ handleRequestBodyProductionEnded()

void Client::handleRequestBodyProductionEnded ( )
protected

◆ haveParsedReplyHeaders()

void Client::haveParsedReplyHeaders ( )
protectedvirtual

◆ initiateAdaptation()

◆ initiated()

◆ maybePurgeOthers()

◆ maybeReadVirginBody()

virtual void Client::maybeReadVirginBody ( )
pure virtual

Implemented in Ftp::Client, and HttpStateData.

Referenced by noteMoreBodySpaceAvailable().

◆ mayReadVirginReplyBody()

virtual bool Client::mayReadVirginReplyBody ( ) const
protectedpure virtual

Implemented in Ftp::Gateway, HttpStateData, and Ftp::Relay.

Referenced by handleAdaptationCompleted().

◆ mustStop()

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

Definition at line 69 of file AsyncJob.cc.

References debugs, AsyncJob::inCall, Must, NULL, AsyncJob::stopReason, and AsyncJob::typeName.

Referenced by HttpStateData::abortAll(), Ftp::Client::abortAll(), Comm::TcpAcceptor::acceptOne(), Adaptation::Ecap::XactionRep::adaptationAborted(), Adaptation::AccessCheck::callBack(), AsyncJob::callException(), Security::PeerConnector::connectionClosed(), HttpStateData::continueAfterParsingHeader(), Ftp::Client::ctrlClosed(), Adaptation::Iterator::handleAdaptationBlock(), Adaptation::Iterator::handleAdaptationError(), Log::TcpLogger::handleClosure(), Adaptation::Icap::Xaction::handleCommClosed(), Http::Tunneler::handleConnectionClosure(), Mgr::Forwarder::handleError(), Ipc::Forwarder::handleError(), Ipc::Forwarder::handleException(), Ipc::Inquirer::handleException(), HttpStateData::handleMoreRequestBodyAvailable(), Ipc::Inquirer::handleRemoteAck(), Ipc::Forwarder::handleTimeout(), HttpStateData::httpStateConnClosed(), HttpStateData::httpTimeout(), Comm::ConnOpener::noteAbort(), Adaptation::Icap::ModXact::noteBodyConsumerAborted(), Snmp::Forwarder::noteCommClosed(), Snmp::Inquirer::noteCommClosed(), Mgr::Inquirer::noteCommClosed(), Mgr::Forwarder::noteCommClosed(), Mgr::StoreToCommWriter::noteCommClosed(), Adaptation::Icap::Xaction::noteCommRead(), Rock::HeaderUpdater::noteDoneReading(), Adaptation::Iterator::noteInitiatorAborted(), Adaptation::Icap::Xaction::noteInitiatorAborted(), Adaptation::Ecap::XactionRep::noteInitiatorAborted(), HttpStateData::readReply(), Comm::ConnOpener::sendAnswer(), Rock::Rebuild::start(), Security::PeerConnector::start(), HttpStateData::start(), Ipc::UdsSender::timedout(), and HttpStateData::wroteLast().

◆ noteAdaptationAclCheckDone()

void Client::noteAdaptationAclCheckDone ( Adaptation::ServiceGroupPointer  group)
virtual

AccessCheck calls this back with a possibly nil service group to signal whether adaptation is needed and where it should start.

Reimplemented from Adaptation::Initiator.

Definition at line 905 of file Client.cc.

References abortOnBadEntry(), adaptationAccessCheckPending, debugs, HERE(), originalRequest(), processReplyBody(), request, sendBodyIsTooLargeError(), setFinalReply(), startAdaptation(), and virginReply().

◆ noteAdaptationAnswer()

void Client::noteAdaptationAnswer ( const Adaptation::Answer answer)
virtual

◆ noteBodyConsumerAborted()

void Client::noteBodyConsumerAborted ( BodyPipe::Pointer  )
virtual

◆ noteBodyProducerAborted()

void Client::noteBodyProducerAborted ( BodyPipe::Pointer  bp)
virtual

◆ noteBodyProductionEnded()

void Client::noteBodyProductionEnded ( BodyPipe::Pointer  bp)
virtual

◆ noteMoreBodyDataAvailable()

void Client::noteMoreBodyDataAvailable ( BodyPipe::Pointer  bp)
virtual

◆ noteMoreBodySpaceAvailable()

void Client::noteMoreBodySpaceAvailable ( BodyPipe::Pointer  )
virtual

◆ originalRequest()

◆ processReplyBody()

virtual void Client::processReplyBody ( )
pure virtual

◆ replyBodySpace()

size_t Client::replyBodySpace ( const MemBuf readBuf,
const size_t  minSpace 
) const
protected

◆ resumeBodyStorage()

void Client::resumeBodyStorage ( )
protected

◆ sendBodyIsTooLargeError()

void Client::sendBodyIsTooLargeError ( )
private

◆ sendMoreRequestBody()

◆ sentRequestBody()

◆ serverComplete()

◆ serverComplete2()

void Client::serverComplete2 ( )
private

Continuation of serverComplete

Definition at line 178 of file Client.cc.

References completeForwarding(), debugs, doneWithAdaptation(), HERE(), NULL, BodyProducer::stopProducingFor(), and virginBodyDestination.

Referenced by noteMoreBodySpaceAvailable(), and serverComplete().

◆ setFinalReply()

◆ setVirginReply()

◆ Start()

◆ start()

◆ startAdaptation()

◆ startRequestBodyFlow()

◆ status()

◆ stopConsumingFrom()

◆ stopProducingFor()

◆ storeReplyBody()

void Client::storeReplyBody ( const char *  buf,
ssize_t  len 
)
protected

Definition at line 993 of file Client.cc.

References currentOffset, entry, len, and StoreEntry::write().

Referenced by addVirginReplyBody().

◆ swanSong()

◆ toCbdata()

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited

◆ virginReply() [1/2]

◆ virginReply() [2/2]

HttpReply * Client::virginReply ( )
protected

Definition at line 103 of file Client.cc.

References assert, and theVirginReply.

Member Data Documentation

◆ adaptationAccessCheckPending

◆ adaptedBodySource

◆ adaptedHeadSource

CbcPointer<Adaptation::Initiate> Client::adaptedHeadSource
protected

to get adapted response headers

Definition at line 174 of file Client.h.

Referenced by cleanAdaptation(), doneWithAdaptation(), noteAdaptationAnswer(), and startAdaptation().

◆ completed

bool Client::completed = false
private

serverComplete() has been called

Definition at line 86 of file Client.h.

Referenced by noteMoreBodySpaceAvailable(), and serverComplete().

◆ currentOffset

int64_t Client::currentOffset = 0
protected

Our current offset in the StoreEntry

Definition at line 160 of file Client.h.

Referenced by handleMoreAdaptedBodyAvailable(), haveParsedReplyHeaders(), and storeReplyBody().

◆ doneWithFwd

const char* Client::doneWithFwd = nullptr
protected

whether we should not be talking to FwdState; XXX: clear fwd instead points to a string literal which is used only for debugging

Definition at line 184 of file Client.h.

Referenced by completeForwarding(), Ftp::Client::ctrlClosed(), HttpStateData::httpStateConnClosed(), and swanSong().

◆ entry

StoreEntry* Client::entry = nullptr

Definition at line 164 of file Client.h.

Referenced by abortOnBadEntry(), Ftp::Gateway::appendSuccessHeader(), blockCaching(), HttpStateData::buildRequestPrefix(), Client(), Ftp::Gateway::completedListing(), HttpStateData::continueAfterParsingHeader(), Ftp::Client::dataRead(), Ftp::Relay::failed(), Ftp::Client::failed(), Ftp::Relay::failedErrorMessage(), Ftp::Relay::forwardReply(), Ftp::Gateway::ftpAcceptDataConnection(), ftpFail(), ftpSendReply(), ftpWriteTransferDone(), Ftp::Gateway::Gateway(), handleAdaptationAborted(), handleAdaptationBlocked(), handleAdaptedBodyProducerAborted(), handledEarlyAdaptationAbort(), handleMoreAdaptedBodyAvailable(), HttpStateData::handleMoreRequestBodyAvailable(), HttpStateData::handleRequestBodyProducerAborted(), HttpStateData::haveParsedReplyHeaders(), Ftp::Gateway::haveParsedReplyHeaders(), HttpStateData::HttpStateData(), HttpStateData::httpTimeout(), HttpStateData::keepaliveAccounting(), Ftp::Gateway::listenForDataChannel(), Ftp::Gateway::loginFailed(), Ftp::Client::maybeReadVirginBody(), Ftp::Gateway::parseListing(), HttpStateData::peerSupportsConnectionPinning(), Ftp::Gateway::processHeadResponse(), Ftp::Relay::processReplyBody(), HttpStateData::processReplyBody(), Ftp::Gateway::processReplyBody(), HttpStateData::processReplyHeader(), HttpStateData::processSurrogateControl(), Ftp::Client::readControlReply(), HttpStateData::readReply(), Ftp::Relay::Relay(), HttpStateData::reusableReply(), sentRequestBody(), setFinalReply(), Ftp::Gateway::start(), HttpStateData::statusIfComplete(), storeReplyBody(), Ftp::Client::timeout(), HttpStateData::wroteLast(), ~Client(), and Ftp::Gateway::~Gateway().

◆ fwd

◆ id

const InstanceId<AsyncJob> AsyncJob::id
protectedinherited

Definition at line 72 of file AsyncJob.h.

◆ inCall

◆ receivedWholeRequestBody

bool Client::receivedWholeRequestBody = false
protected

◆ request

◆ requestBodySource

◆ requestSender

◆ responseBodyBuffer

MemBuf* Client::responseBodyBuffer = nullptr
protected

Data temporarily buffered for ICAP

Definition at line 161 of file Client.h.

Referenced by adaptVirginReplyBody(), calcBufferSpaceToReserve(), noteMoreBodySpaceAvailable(), replyBodySpace(), serverComplete(), and ~Client().

◆ startedAdaptation

bool Client::startedAdaptation = false
protected

Definition at line 178 of file Client.h.

Referenced by adaptVirginReplyBody(), addVirginReplyBody(), and startAdaptation().

◆ stopReason

const char* AsyncJob::stopReason
protectedinherited

◆ theFinalReply

HttpReply* Client::theFinalReply = nullptr
private

adapted reply from ICAP or virgin reply

Definition at line 191 of file Client.h.

Referenced by finalReply(), haveParsedReplyHeaders(), maybePurgeOthers(), setFinalReply(), and ~Client().

◆ theVirginReply

HttpReply* Client::theVirginReply = nullptr
private

reply received from the origin server

Definition at line 190 of file Client.h.

Referenced by setVirginReply(), virginReply(), and ~Client().

◆ typeName

◆ virginBodyDestination

BodyPipe::Pointer Client::virginBodyDestination
protected

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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors