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

Definition at line 25 of file BodyPipe.h.

Definition at line 34 of file AsyncJob.h.

Definition at line 45 of file BodyPipe.h.

Constructor & Destructor Documentation

Client::Client ( FwdState theFwdState)

Definition at line 39 of file Client.cc.

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

Client::~Client ( )

Member Function Documentation

virtual void Client::abortAll ( const char *  reason)
pure virtual
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 287 of file Client.cc.

References abortAll().

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

void Client::adaptVirginReplyBody ( const char *  buf,
ssize_t  len 
void Client::addVirginReplyBody ( const char *  buf,
ssize_t  len 
void Client::adjustBodyBytesRead ( const int64_t  delta)

Definition at line 962 of file Client.cc.

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

Referenced by addVirginReplyBody().

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

Definition at line 38 of file Initiator.cc.

References CallJobHere.

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

size_t Client::calcBufferSpaceToReserve ( const size_t  space,
const size_t  wantSpace 
) const
void AsyncJob::callEnd ( )
void AsyncJob::callStart ( AsyncCall call)
bool AsyncJob::canBeCalled ( AsyncCall call) const

Definition at line 101 of file AsyncJob.cc.

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

void Adaptation::Initiator::clearAdaptation ( CbcPointer< Initiate > &  x)
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().

void Client::completeForwarding ( )

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

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

Implemented in Ftp::Client, and HttpStateData.

Referenced by sendMoreRequestBody().

void AsyncJob::deleteThis ( const char *  aReason)
bool AsyncJob::done ( ) const

Definition at line 90 of file AsyncJob.cc.

References AsyncJob::doneAll(), NULL, and AsyncJob::stopReason.

Referenced by AsyncJob::callEnd(), and Downloader::downloadFinished().

bool Client::doneAll ( ) const

Reimplemented from AsyncJob.

Definition at line 193 of file Client.cc.

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

void Client::doneSendingRequestBody ( )
protectedpure virtual
bool Client::doneWithAdaptation ( ) const
virtual bool Client::doneWithServer ( ) const
protectedpure virtual

did we end communication?

Implemented in Ftp::Client, and HttpStateData.

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

void Client::endAdaptedBodyConsumption ( )
HttpReply * Client::finalReply ( )

Definition at line 128 of file Client.cc.

References assert, and theFinalReply.

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

bool Client::getMoreRequestBody ( MemBuf buf)

Reimplemented in HttpStateData.

Definition at line 414 of file Client.cc.

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

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

void Client::handleAdaptationAborted ( bool  bypassable = false)
void Client::handleAdaptationCompleted ( )
void Client::handleAdaptedBodyProductionEnded ( )
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 855 of file Client.cc.

References abortAll(), 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().

void Client::handleMoreRequestBodyAvailable ( )

Definition at line 295 of file Client.cc.

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

Referenced by noteMoreBodyDataAvailable().

void Client::handleRequestBodyProductionEnded ( )
void Client::haveParsedReplyHeaders ( )
CbcPointer< Adaptation::Initiate > Adaptation::Initiator::initiateAdaptation ( Initiate x)
bool Adaptation::Initiator::initiated ( const CbcPointer< AsyncJob > &  job) const

Definition at line 52 of file Initiator.h.

References CbcPointer< Cbc >::set().

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

virtual void Client::maybeReadVirginBody ( )
pure virtual

Implemented in Ftp::Client, and HttpStateData.

Referenced by noteMoreBodySpaceAvailable().

virtual bool Client::mayReadVirginReplyBody ( ) const
protectedpure virtual

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

Referenced by handleAdaptationCompleted().

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

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

void Client::noteAdaptationAnswer ( const Adaptation::Answer answer)
void Client::noteBodyConsumerAborted ( BodyPipe::Pointer  )
void Client::noteBodyProducerAborted ( BodyPipe::Pointer  bp)
void Client::noteBodyProductionEnded ( BodyPipe::Pointer  bp)
void Client::noteMoreBodyDataAvailable ( BodyPipe::Pointer  bp)
void Client::noteMoreBodySpaceAvailable ( BodyPipe::Pointer  )
virtual void Client::processReplyBody ( )
pure virtual

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

Referenced by noteAdaptationAclCheckDone().

size_t Client::replyBodySpace ( const MemBuf readBuf,
const size_t  minSpace 
) const
void Client::resumeBodyStorage ( )
void Client::sendBodyIsTooLargeError ( )
void Client::serverComplete2 ( )

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

HttpReply * Client::setVirginReply ( HttpReply r)

Definition at line 117 of file Client.cc.

References assert, debugs, HERE(), HTTPMSGLOCK(), and theVirginReply.

Referenced by HttpStateData::processReplyHeader().

bool Client::startRequestBodyFlow ( )
void BodyProducer::stopProducingFor ( RefCount< BodyPipe > &  p,
bool  atEof 
void Client::storeReplyBody ( const char *  buf,
ssize_t  len 

Definition at line 993 of file Client.cc.

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

Referenced by addVirginReplyBody().

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited
HttpReply * Client::virginReply ( )

Definition at line 103 of file Client.cc.

References assert, and theVirginReply.

Member Data Documentation

bool Client::adaptationAccessCheckPending = false
CbcPointer<Adaptation::Initiate> Client::adaptedHeadSource

to get adapted response headers

Definition at line 174 of file Client.h.

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

bool Client::completed = false

serverComplete() has been called

Definition at line 86 of file Client.h.

Referenced by noteMoreBodySpaceAvailable(), and serverComplete().

int64_t Client::currentOffset = 0
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 184 of file Client.h.

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

const InstanceId<AsyncJob> AsyncJob::id

Definition at line 72 of file AsyncJob.h.

AsyncCall::Pointer AsyncJob::inCall
bool Client::receivedWholeRequestBody = false
MemBuf* Client::responseBodyBuffer = nullptr

Data temporarily buffered for ICAP

Definition at line 161 of file Client.h.

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

bool Client::startedAdaptation = false

Definition at line 178 of file Client.h.

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

const char* AsyncJob::stopReason
HttpReply* Client::theFinalReply = nullptr

adapted reply from ICAP or virgin reply

Definition at line 191 of file Client.h.

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

HttpReply* Client::theVirginReply = nullptr

reply received from the origin server

Definition at line 190 of file Client.h.

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

BodyPipe::Pointer Client::virginBodyDestination

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






Web Site Translations