#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 *)
 ~Client () override
virtual const Comm::ConnectionPointerdataConnection () const =0
void noteMoreBodyDataAvailable (BodyPipe::Pointer) override
void noteBodyProductionEnded (BodyPipe::Pointer) override
void noteBodyProducerAborted (BodyPipe::Pointer) override
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...
void noteAdaptationAnswer (const Adaptation::Answer &answer) override
void noteAdaptationAclCheckDone (Adaptation::ServiceGroupPointer group) override
void noteMoreBodySpaceAvailable (BodyPipe::Pointer) override
void noteBodyConsumerAborted (BodyPipe::Pointer) override
virtual bool getMoreRequestBody (MemBuf &buf)
 either fill buf with available [encoded] request body bytes or return false More...
virtual void processReplyBody ()=0
void swanSong () override
bool doneAll () const override
 whether positive goal has been reached More...
void serverComplete ()
void markParsedVirginReplyAsWhole (const char *reasonWeAreSure)
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

StoreEntryentry = nullptr
FwdState::Pointer fwd
HttpRequestPointer request
const InstanceId< AsyncJobid
 job identifier More...

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...
virtual void noteDelayAwareReadChance ()=0
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...
void delayRead ()
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 > &)

Static Protected Member Functions

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

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 receivedWholeAdaptedReply = false
 handleAdaptedBodyProductionEnded() was called More...
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...
bool started_ = false
 Start() has finished successfully. More...
bool swanSang_ = false
 swanSong() was called More...

Private Member Functions

void serverComplete2 ()
void sendBodyIsTooLargeError ()
void maybePurgeOthers ()
virtual void finalizedInCbdataChild ()=0
 hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE() More...

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 34 of file AsyncJob.h.

◆ Pointer [2/3]

Definition at line 25 of file BodyPipe.h.

◆ Pointer [3/3]

Definition at line 45 of file BodyPipe.h.

Constructor & Destructor Documentation

◆ Client()

Client::Client ( FwdState theFwdState)

Definition at line 38 of file Client.cc.

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

◆ ~Client()

Member Function Documentation

◆ abortAll()

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

◆ abortOnBadEntry()

◆ abortOnData()

bool Client::abortOnData ( const char *  reason)

abnormal data transfer termination

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

Reimplemented in Ftp::Relay.

Definition at line 311 of file Client.cc.

References abortAll().

Referenced by abortOnBadEntry(), handleAdaptationBlocked(), sendBodyIsTooLargeError(), and sentRequestBody().

◆ adaptOrFinalizeReply()

◆ adaptVirginReplyBody()

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

◆ addVirginReplyBody()

void Client::addVirginReplyBody ( const char *  buf,
ssize_t  len 

◆ adjustBodyBytesRead()

void Client::adjustBodyBytesRead ( const int64_t  delta)

Definition at line 1014 of file Client.cc.

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

Referenced by addVirginReplyBody().

◆ announceInitiatorAbort()

void Adaptation::Initiator::announceInitiatorAbort ( CbcPointer< Initiate > &  x)

Definition at line 38 of file Initiator.cc.

References CallJobHere.

Referenced by ClientHttpRequest::~ClientHttpRequest(), and cleanAdaptation().

◆ blockCaching()

◆ calcBufferSpaceToReserve()

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

◆ callEnd()

void AsyncJob::callEnd ( )

◆ callException()

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const

Definition at line 117 of file AsyncJob.cc.

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

◆ cleanAdaptation()

◆ clearAdaptation()

void Adaptation::Initiator::clearAdaptation ( CbcPointer< Initiate > &  x)

◆ 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 ( )

default calls fwd->complete()

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

Definition at line 230 of file Client.cc.

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

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

◆ dataConnection()

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

Implemented in Ftp::Client, and HttpStateData.

Referenced by sendMoreRequestBody().

◆ delayRead()

void Client::delayRead ( )

Defer reading until it is likely to become possible. Eventually, noteDelayAwareReadChance() will be called.

Definition at line 1029 of file Client.cc.

References asyncCall(), MemObject::delayRead(), entry, StoreEntry::mem(), and noteDelayAwareReadChance().

Referenced by HttpStateData::readReply().

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)

◆ done()

bool AsyncJob::done ( ) const

◆ doneAll()

bool Client::doneAll ( ) const

Reimplemented from AsyncJob.

Definition at line 217 of file Client.cc.

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

◆ doneSendingRequestBody()

void Client::doneSendingRequestBody ( )
protectedpure virtual

◆ doneWithAdaptation()

bool Client::doneWithAdaptation ( ) const

◆ 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()

◆ finalizedInCbdataChild()

virtual void CbdataParent::finalizedInCbdataChild ( )
privatepure virtualinherited

◆ finalReply()

HttpReply * Client::finalReply ( )

Definition at line 129 of file Client.cc.

References assert, and theFinalReply.

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

◆ getMoreRequestBody()

bool Client::getMoreRequestBody ( MemBuf buf)

Reimplemented in HttpStateData.

Definition at line 438 of file Client.cc.

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

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

◆ handleAdaptationAborted()

void Client::handleAdaptationAborted ( bool  bypassable = false)

◆ handleAdaptationBlocked()

◆ handleAdaptationCompleted()

void Client::handleAdaptationCompleted ( )

◆ handleAdaptedBodyProducerAborted()

void Client::handleAdaptedBodyProducerAborted ( )

◆ handleAdaptedBodyProductionEnded()

void Client::handleAdaptedBodyProductionEnded ( )

◆ handleAdaptedHeader()

◆ handledEarlyAdaptationAbort()

bool Client::handledEarlyAdaptationAbort ( )

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 901 of file Client.cc.

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

Referenced by handleAdaptationAborted(), and handleAdaptedBodyProducerAborted().

◆ handleMoreAdaptedBodyAvailable()

◆ handleMoreRequestBodyAvailable()

void Client::handleMoreRequestBodyAvailable ( )

Definition at line 319 of file Client.cc.

References debugs, requestSender, and sendMoreRequestBody().

Referenced by noteMoreBodyDataAvailable().

◆ handleRequestBodyProducerAborted()

◆ handleRequestBodyProductionEnded()

void Client::handleRequestBodyProductionEnded ( )

Definition at line 329 of file Client.cc.

References debugs, doneSendingRequestBody(), receivedWholeRequestBody, and requestSender.

Referenced by noteBodyProductionEnded().

◆ handleStopRequest()

void AsyncJob::handleStopRequest ( )

Definition at line 73 of file AsyncJob.h.

References AsyncJob::mustStop().

◆ haveParsedReplyHeaders()

void Client::haveParsedReplyHeaders ( )

◆ initiateAdaptation()

CbcPointer< Adaptation::Initiate > Adaptation::Initiator::initiateAdaptation ( Initiate x)

◆ initiated()

bool Adaptation::Initiator::initiated ( const CbcPointer< AsyncJob > &  job) const

Definition at line 52 of file Initiator.h.

References CbcPointer< Cbc >::set().

Referenced by ClientHttpRequest::startAdaptation(), and startAdaptation().

◆ markParsedVirginReplyAsWhole()

void Client::markParsedVirginReplyAsWhole ( const char *  reasonWeAreSure)

remember that the received virgin reply was parsed in its entirety, including its body (if any)

Definition at line 158 of file Client.cc.

References assert, debugs, fwd, FwdState::markStoredReplyAsWhole(), and startedAdaptation.

Referenced by HttpStateData::decodeAndWriteReplyBody(), ftpReadTransferDone(), and HttpStateData::writeReplyBody().

◆ 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, Ftp::Relay, and HttpStateData.

Referenced by handleAdaptationCompleted().

◆ mustStop()

◆ noteAdaptationAclCheckDone()

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

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 957 of file Client.cc.

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

◆ noteAdaptationAnswer()

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

◆ noteBodyConsumerAborted()

void Client::noteBodyConsumerAborted ( BodyPipe::Pointer  )

◆ noteBodyProducerAborted()

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

◆ noteBodyProductionEnded()

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

◆ noteDelayAwareReadChance()

virtual void Client::noteDelayAwareReadChance ( )
protectedpure virtual

Called when a previously delayed dataConnection() read may be possible.

See also

Implemented in Ftp::Client, and HttpStateData.

Referenced by delayRead().

◆ noteMoreBodyDataAvailable()

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

◆ noteMoreBodySpaceAvailable()

void Client::noteMoreBodySpaceAvailable ( BodyPipe::Pointer  )

◆ originalRequest()

◆ processReplyBody()

virtual void Client::processReplyBody ( )
pure virtual

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

Referenced by noteAdaptationAclCheckDone().

◆ RegisterWithCacheManager()

void AsyncJob::RegisterWithCacheManager ( )

Definition at line 215 of file AsyncJob.cc.

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

Referenced by mainInitialize().

◆ replyBodySpace()

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

◆ ReportAllJobs()

void AsyncJob::ReportAllJobs ( StoreEntry e)

Definition at line 198 of file AsyncJob.cc.

References AllJobs().

Referenced by AsyncJob::RegisterWithCacheManager().

◆ resumeBodyStorage()

void Client::resumeBodyStorage ( )

◆ sendBodyIsTooLargeError()

void Client::sendBodyIsTooLargeError ( )

◆ sendMoreRequestBody()

◆ sentRequestBody()

◆ serverComplete()

◆ serverComplete2()

void Client::serverComplete2 ( )

Continuation of serverComplete

Definition at line 202 of file Client.cc.

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

Referenced by noteMoreBodySpaceAvailable(), and serverComplete().

◆ setFinalReply()

◆ setVirginReply()

HttpReply * Client::setVirginReply ( HttpReply r)

◆ start()

◆ Start()

◆ startAdaptation()

◆ startRequestBodyFlow()

bool Client::startRequestBodyFlow ( )

◆ status()

◆ stopConsumingFrom()

◆ stopProducingFor()

void BodyProducer::stopProducingFor ( RefCount< BodyPipe > &  p,
bool  atEof 

◆ storeReplyBody()

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

Definition at line 1054 of file Client.cc.

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

Referenced by addVirginReplyBody().

◆ swanSong()

◆ toCbdata()

virtual void * CbdataParent::toCbdata ( )
pure virtualinherited

◆ virginReply() [1/2]

HttpReply * Client::virginReply ( )

Definition at line 102 of file Client.cc.

References assert, and theVirginReply.

◆ virginReply() [2/2]

Member Data Documentation

◆ adaptationAccessCheckPending

bool Client::adaptationAccessCheckPending = false

◆ adaptedBodySource

◆ adaptedHeadSource

CbcPointer<Adaptation::Initiate> Client::adaptedHeadSource

to get adapted response headers

Definition at line 186 of file Client.h.

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

◆ completed

bool Client::completed = false

serverComplete() has been called

Definition at line 90 of file Client.h.

Referenced by noteMoreBodySpaceAvailable(), and serverComplete().

◆ currentOffset

int64_t Client::currentOffset = 0

◆ doneWithFwd

const char* Client::doneWithFwd = nullptr

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 199 of file Client.h.

Referenced by completeForwarding(), HttpStateData::httpStateConnClosed(), HttpStateData::proceedAfter1xx(), and swanSong().

◆ entry

◆ fwd

◆ id

const InstanceId<AsyncJob> AsyncJob::id

Definition at line 75 of file AsyncJob.h.

◆ inCall

AsyncCall::Pointer AsyncJob::inCall

◆ receivedWholeAdaptedReply

bool Client::receivedWholeAdaptedReply = false

Definition at line 193 of file Client.h.

Referenced by endAdaptedBodyConsumption(), and handleAdaptedBodyProductionEnded().

◆ receivedWholeRequestBody

bool Client::receivedWholeRequestBody = false

◆ request

◆ requestBodySource

◆ requestSender

◆ responseBodyBuffer

MemBuf* Client::responseBodyBuffer = nullptr

Data temporarily buffered for ICAP

Definition at line 173 of file Client.h.

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

◆ started_

bool AsyncJob::started_ = false

Definition at line 88 of file AsyncJob.h.

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

◆ startedAdaptation

bool Client::startedAdaptation = false

◆ stopReason

const char* AsyncJob::stopReason

◆ swanSang_

bool AsyncJob::swanSang_ = false

Definition at line 89 of file AsyncJob.h.

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

◆ theFinalReply

HttpReply* Client::theFinalReply = nullptr

adapted reply from ICAP or virgin reply

Definition at line 206 of file Client.h.

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

◆ theVirginReply

HttpReply* Client::theVirginReply = nullptr

reply received from the origin server

Definition at line 205 of file Client.h.

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

◆ typeName

◆ virginBodyDestination

BodyPipe::Pointer Client::virginBodyDestination

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






Web Site Translations