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

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

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

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

◆ ~Client()

Client::~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 312 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 1015 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 102 of file AsyncJob.cc.

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

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

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

◆ completeForwarding()

void Client::completeForwarding ( )

default calls fwd->complete()

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

Definition at line 231 of file Client.cc.

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

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

Referenced by sendMoreRequestBody().

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)

◆ done()

bool AsyncJob::done ( ) const

◆ doneAll()

bool Client::doneAll ( ) const

Reimplemented from AsyncJob.

Definition at line 218 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 HttpStateData, and Ftp::Client.

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

◆ endAdaptedBodyConsumption()

◆ finalReply()

HttpReply * Client::finalReply ( )

Definition at line 130 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 439 of file Client.cc.

References BodyPipe::getMoreData(), Must, NULL, 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 902 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 320 of file Client.cc.

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

Referenced by noteMoreBodyDataAvailable().

◆ handleRequestBodyProducerAborted()

◆ handleRequestBodyProductionEnded()

void Client::handleRequestBodyProductionEnded ( )

◆ handleStopRequest()

void AsyncJob::handleStopRequest ( )

Definition at line 71 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 159 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 HttpStateData, and Ftp::Client.

Referenced by noteMoreBodySpaceAvailable().

◆ mayReadVirginReplyBody()

virtual bool Client::mayReadVirginReplyBody ( ) const
protectedpure virtual

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

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 958 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)

◆ noteBodyConsumerAborted()

void Client::noteBodyConsumerAborted ( BodyPipe::Pointer  )

◆ noteBodyProducerAborted()

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

◆ noteBodyProductionEnded()

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

◆ noteMoreBodyDataAvailable()

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

◆ noteMoreBodySpaceAvailable()

void Client::noteMoreBodySpaceAvailable ( BodyPipe::Pointer  )

◆ originalRequest()

◆ processReplyBody()

virtual void Client::processReplyBody ( )
pure virtual

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

Referenced by noteAdaptationAclCheckDone().

◆ replyBodySpace()

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

◆ resumeBodyStorage()

void Client::resumeBodyStorage ( )

◆ sendBodyIsTooLargeError()

void Client::sendBodyIsTooLargeError ( )

◆ sendMoreRequestBody()

◆ sentRequestBody()

◆ serverComplete()

◆ serverComplete2()

void Client::serverComplete2 ( )

Continuation of serverComplete

Definition at line 203 of file Client.cc.

References completeForwarding(), debugs, doneWithAdaptation(), HERE(), NULL, 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 1046 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 103 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 178 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 191 of file Client.h.

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

◆ entry

◆ fwd

◆ id

const InstanceId<AsyncJob> AsyncJob::id

Definition at line 73 of file AsyncJob.h.

◆ inCall

AsyncCall::Pointer AsyncJob::inCall

◆ receivedWholeAdaptedReply

bool Client::receivedWholeAdaptedReply = false

Definition at line 185 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 165 of file Client.h.

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

◆ started_

bool AsyncJob::started_ = false

Definition at line 83 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 84 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 198 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 197 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