#include <client_side_reply.h>

Inheritance diagram for clientReplyContext:
Collaboration diagram for clientReplyContext:


struct  Flags

Public Member Functions

void * operator new (size_t size)
void operator delete (void *address)
void * toCbdata () noexcept
 clientReplyContext (ClientHttpRequest *)
 ~clientReplyContext ()
void saveState ()
void restoreState ()
void purgeRequest ()
void purgeRequestFindObjectToPurge ()
void purgeDoMissPurge ()
void purgeFoundGet (StoreEntry *newEntry)
void purgeFoundHead (StoreEntry *newEntry)
void purgeFoundObject (StoreEntry *entry)
void sendClientUpstreamResponse ()
void purgeDoPurgeGet (StoreEntry *entry)
void purgeDoPurgeHead (StoreEntry *entry)
void doGetMoreData ()
void identifyStoreObject ()
void identifyFoundObject (StoreEntry *entry)
int storeOKTransferDone () const
int storeNotOKTransferDone () const
void setReplyToStoreEntry (StoreEntry *e, const char *reason)
 replaces current response store entry with the given one More...
void setReplyToError (err_type, Http::StatusCode, const HttpRequestMethod &, char const *, Ip::Address &, HttpRequest *, const char *, Auth::UserRequest::Pointer)
 builds error using clientBuildError() and calls setReplyToError() below More...
void setReplyToError (const HttpRequestMethod &method, ErrorState *err)
 creates a store entry for the reply and appends err to it More...
void setReplyToReply (HttpReply *reply)
 creates a store entry for the reply and appends error reply to it More...
void createStoreEntry (const HttpRequestMethod &m, RequestFlags flags)
void removeStoreReference (store_client **scp, StoreEntry **ep)
void removeClientStoreReference (store_client **scp, ClientHttpRequest *http)
void startError (ErrorState *err)
void processExpired ()
clientStream_status_t replyStatus ()
void processMiss ()
void traceReply (clientStreamNode *node)
const char * storeId () const
virtual void created (StoreEntry *newEntry)
virtual LogTagsloggingTags ()

Public Attributes

Http::StatusCode purgeStatus
int lookingforstore
int headers_sz
StoreIOBuffer tempBuffer
int old_reqsize
size_t reqsize
size_t reqofs
char tempbuf [HTTP_REQBUF_SZ]
 a temporary buffer if we need working storage More...
const char * lookup_type
struct clientReplyContext::Flags flags

Static Public Attributes

static STCB CacheHit
static STCB HandleIMSReply
static STCB SendMoreData

Protected Member Functions

bool startCollapsingOn (const StoreEntry &, const bool doingRevalidation)
bool mayInitiateCollapsing () const
 whether Squid configuration allows us to become a CF initiator More...
bool onCollapsingPath () const
 whether Squid configuration allows collapsing for this transaction More...

Private Types

enum  CollapsedRevalidation {
  crNone = 0,

Private Member Functions

virtual void fillChecklist (ACLFilledChecklist &) const
 configure the ACL checklist with the current transaction state More...
clientStreamNodegetNextNode () const
void makeThisHead ()
bool errorInStream (StoreIOBuffer const &result, size_t const &sizeToProcess) const
void sendStreamError (StoreIOBuffer const &result)
void pushStreamData (StoreIOBuffer const &result, char *source)
clientStreamNodenext () const
void processReplyAccess ()
void processReplyAccessResult (const Acl::Answer &accessAllowed)
void cloneReply ()
void buildReplyHeader ()
bool alwaysAllowResponse (Http::StatusCode sline) const
int checkTransferDone ()
void processOnlyIfCachedMiss ()
bool processConditional (StoreIOBuffer &result)
 process conditional request from client More...
void cacheHit (StoreIOBuffer result)
void handleIMSReply (StoreIOBuffer result)
void sendMoreData (StoreIOBuffer result)
void triggerInitialStoreRead ()
void sendClientOldEntry ()
void purgeAllCached ()
void forgetHit ()
bool blockedHit () const
 whether squid.conf send_hit prevents us from serving this hit More...
void sendBodyTooLargeError ()
void sendPreconditionFailedError ()
 send 412 (Precondition Failed) to client More...
void sendNotModified ()
 send 304 (Not Modified) to client More...
void sendNotModifiedOrPreconditionFailedError ()

Private Attributes

StoreIOBuffer holdingBuffer
time_t old_lastmod
String old_etag
bool deleting
CollapsedRevalidation collapsedRevalidation

Static Private Attributes

static cbdata_type CBDATA_clientReplyContext = CBDATA_UNKNOWN
static ACLCB ProcessReplyAccessResult

Detailed Description

Definition at line 22 of file client_side_reply.h.

Member Enumeration Documentation

◆ CollapsedRevalidation


collapsed revalidation is not allowed for this context


we initiated collapsed revalidation request


we collapsed on the existing revalidation request

Definition at line 147 of file client_side_reply.h.

Constructor & Destructor Documentation

◆ clientReplyContext()

clientReplyContext::clientReplyContext ( ClientHttpRequest clientContext)

Definition at line 75 of file client_side_reply.cc.

References tempbuf.

◆ ~clientReplyContext()

Member Function Documentation

◆ alwaysAllowResponse()

bool clientReplyContext::alwaysAllowResponse ( Http::StatusCode  sline) const

◆ blockedHit()

◆ buildReplyHeader()

void clientReplyContext::buildReplyHeader ( )

Generate the reply headers sent to client.

Filters out unwanted entries and hop-by-hop from original reply header then adds extra entries if we have more info than origin server then adds Squid specific entries

alter errorstate to be accel on|off aware. The 0 on the next line depends on authenticate behaviour: all schemes to date send no extra data on 407/401 responses, and do not check the accel state on 401/407 responses

Definition at line 1384 of file client_side_reply.cc.

References ClientHttpRequest::Flags::accel, RequestFlags::accelerated, Auth::UserRequest::AddReplyAuthHeader(), HttpHeader::addVia(), Http::AGE, ClientHttpRequest::al, HttpRequest::auth_user_request, HttpReply::bodySize(), RequestFlags::chunkedReply, SquidConfig::client_pconns, collapsedRevalidation, Config, conn, Http::CONNECTION, RequestFlags::connectionAuth, RequestFlags::connectionAuthDisabled, crSlave, Http::DATE, DBG_IMPORTANT, debugs, HttpHeader::delAt(), HttpHeader::delById(), StoreEntry::dump(), EBIT_TEST, ENTRY_SPECIAL, SquidConfig::error_pconns, Http::EXPIRES, StoreEntry::expires, fdUsageHigh(), HttpHeader::findEntry(), ClientHttpRequest::flags, HttpRequest::flags, StoreEntry::flags, ClientHttpRequest::getConn(), HttpHeader::getEntry(), getMyHostname(), getMyPort(), HttpHeader::has(), Http::Message::header, http, Http::Message::http_ver, httpHdrMangleList(), HttpHeaderInitPos, httpHeaderPutStrf(), HttpHeaderEntry::id, RequestFlags::intercepted, Comm::IsConnOpen(), LogTags::isTcpHit(), HttpReply::keep_alive, LOG_TCP_DENIED, ClientHttpRequest::logType, lookup_type, ClientHttpRequest::memObject(), HttpRequest::method, HttpRequest::multipartRangeRequest(), RequestFlags::mustKeepalive, RequestFlags::needValidation, NULL, LogTags::oldType, SquidConfig::onoff, HttpRequest::peer_login, Http::Message::persistent(), HttpRequest::pinnedConnection(), ConnStateData::port, PRId64, AnyP::PROTO_HTTP, Http::StatusLine::protocol, Http::ProtocolVersion(), Http::PROXY_AUTHENTICATE, Http::PROXY_SUPPORT, RequestFlags::proxyKeepalive, HttpHeader::putExt(), HttpHeader::putInt(), HttpHeader::putStr(), HttpHeader::putTime(), HttpHeader::putWarning(), String::rawBuf(), HttpHeader::refreshMask(), HttpHeader::removeHopByHopEntries(), HttpReply::removeIrrelevantContentLength(), reply, ClientHttpRequest::request, request(), ClientHttpRequest::requestSatisfactionMode(), ROR_REPLY, Http::scProxyAuthenticationRequired, Http::scUnauthorized, Http::SET_COOKIE, shutting_down, HttpReply::sline, squid_curtime, RequestFlags::sslBumped, RequestFlags::staleIfHit, Http::StatusLine::status(), ClientHttpRequest::storeEntry(), Http::SURROGATE_CAPABILITY, Http::SURROGATE_CONTROL, String::termedBuf(), StoreEntry::timestamp, Http::TRANSFER_ENCODING, ClientHttpRequest::uri, HttpHeaderEntry::value, Http::StatusLine::version, Http::WWW_AUTHENTICATE, Http::X_CACHE, Http::X_CACHE_LOOKUP, and Http::X_REQUEST_URI.

Referenced by cloneReply().

◆ cacheHit()

void clientReplyContext::cacheHit ( StoreIOBuffer  result)

◆ checkTransferDone()

◆ cloneReply()

◆ created()

void clientReplyContext::created ( StoreEntry )

Handle a StoreEntry::getPublic*() result. A nil entry indicates a cache miss.

Implements StoreClient.

Definition at line 936 of file client_side_reply.cc.

References identifyFoundObject(), lookingforstore, purgeDoPurgeGet(), purgeDoPurgeHead(), purgeFoundGet(), and purgeFoundHead().

◆ createStoreEntry()

◆ doGetMoreData()

◆ errorInStream()

bool clientReplyContext::errorInStream ( StoreIOBuffer const &  result,
size_t const &  sizeToProcess 
) const

◆ fillChecklist()

void clientReplyContext::fillChecklist ( ACLFilledChecklist checklist) const

Implements StoreClient.

Definition at line 2262 of file client_side_reply.cc.

References clientAclChecklistFill(), and http.

◆ forgetHit()

void clientReplyContext::forgetHit ( )

Safely disposes of an entry pointing to a cache hit that we do not want. We cannot just ignore the entry because it may be locking or otherwise holding an associated cache resource of some sort.

Definition at line 1667 of file client_side_reply.cc.

References assert, http, StoreEntry::lock(), NULL, ClientHttpRequest::storeEntry(), and StoreEntry::unlock().

Referenced by identifyFoundObject().

◆ getNextNode()

clientStreamNode * clientReplyContext::getNextNode ( ) const

Definition at line 248 of file client_side_reply.cc.

References dlink_node::data, dlink_node::next, clientStreamNode::node, and ourNode.

Referenced by doGetMoreData(), and next().

◆ handleIMSReply()

◆ identifyFoundObject()

void clientReplyContext::identifyFoundObject ( StoreEntry newEntry)

Check state of the current StoreEntry object. to see if we can determine the final status of the request.

  • If the request has no-cache flag set or some no_cache HACK in operation we 'invalidate' the cached IP entries for this request ???
  • If no StoreEntry object is current assume this object isn't in the cache set MISS
  • If we are running in offline mode set to HIT
  • If redirection status is True force this to be a MISS

Definition at line 1700 of file client_side_reply.cc.

References Config, debugs, doGetMoreData(), EBIT_TEST, ENTRY_SPECIAL, HttpRequest::flags, forgetHit(), AnyP::Uri::host(), http, ipcacheInvalidateNegative(), LOG_TCP_CLIENT_REFRESH_MISS, LOG_TCP_HIT, LOG_TCP_MISS, LOG_TCP_REDIRECT, ClientHttpRequest::logType, lookup_type, RequestFlags::noCache, RequestFlags::noCacheHack(), SquidConfig::offline, SquidConfig::onoff, ClientHttpRequest::redirect, ClientHttpRequest::request, StoreClient::startCollapsingOn(), ClientHttpRequest::Redirect::status, ClientHttpRequest::storeEntry(), LogTags::update(), and HttpRequest::url.

Referenced by created(), and identifyStoreObject().

◆ identifyStoreObject()

◆ loggingTags()

LogTags * clientReplyContext::loggingTags ( )
LogTags (if the class logs transactions) or nil (otherwise)

Implements StoreClient.

Definition at line 951 of file client_side_reply.cc.

References http, and ClientHttpRequest::logType.

◆ makeThisHead()

void clientReplyContext::makeThisHead ( )

◆ mayInitiateCollapsing()

bool StoreClient::mayInitiateCollapsing ( ) const

Definition at line 51 of file StoreClient.h.

References StoreClient::onCollapsingPath().

Referenced by createStoreEntry(), and processExpired().

◆ next()

◆ onCollapsingPath()

◆ operator delete()

void clientReplyContext::operator delete ( void *  address)

Definition at line 24 of file client_side_reply.h.

◆ operator new()

void* clientReplyContext::operator new ( size_t  size)

Definition at line 24 of file client_side_reply.h.

◆ processConditional()

◆ processExpired()

◆ processMiss()

void clientReplyContext::processMiss ( )

Prepare to fetch the object as it's a cache miss of some kind.

We might have a left-over StoreEntry from a failed cache hit or IMS request.

Check if its a PURGE request to be actioned.

Check if its an 'OTHER' request. Purge all cached entries if so and continue.

Check if 'only-if-cached' flag is set. Action if so.

Deny loops

Start forwarding to get the new object from network

Definition at line 726 of file client_side_reply.cc.

References ClientHttpRequest::al, assert, LogTags::c_str(), clientBuildError(), Server::clientConnection, HttpRequest::clientConnectionManager, AccessLogEntry::HttpDetails::code, StoreEntry::complete(), conn, createStoreEntry(), DBG_CRITICAL, debugs, StoreEntry::dump(), EBIT_TEST, ENTRY_SPECIAL, ERR_ACCESS_DENIED, errorAppendEntry(), HttpRequest::flags, StoreEntry::flags, ClientHttpRequest::getConn(), http, AccessLogEntry::http, ClientHttpRequest::Redirect::location, LOG_TCP_REDIRECT, ClientHttpRequest::logType, RequestFlags::loopDetected, HttpRequest::method, Http::METHOD_OTHER, Http::METHOD_PURGE, NULL, ClientHttpRequest::Out::offset, ClientHttpRequest::onlyIfCached(), ClientHttpRequest::out, processOnlyIfCachedMiss(), purgeAllCached(), purgeRequest(), HttpReply::redirect(), ClientHttpRequest::redirect, StoreEntry::releaseRequest(), Comm::Connection::remote, removeClientStoreReference(), StoreEntry::replaceHttpReply(), ClientHttpRequest::request, sc, Http::scForbidden, Ip::Address::setNoAddr(), FwdState::Start(), ClientHttpRequest::Redirect::status, ClientHttpRequest::storeEntry(), triggerInitialStoreRead(), LogTags::update(), and ClientHttpRequest::uri.

Referenced by cacheHit(), doGetMoreData(), handleIMSReply(), and processConditional().

◆ processOnlyIfCachedMiss()

void clientReplyContext::processOnlyIfCachedMiss ( )

client issued a request with an only-if-cached cache-control directive; we did not find a cached object that can be returned without contacting other servers; respond with a 504 (Gateway Timeout) as suggested in [RFC 2068]

Definition at line 804 of file client_side_reply.cc.

References ClientHttpRequest::al, clientBuildError(), Server::clientConnection, AccessLogEntry::HttpDetails::code, debugs, ERR_ONLY_IF_CACHED_MISS, ClientHttpRequest::getConn(), http, AccessLogEntry::http, HttpRequest::method, NULL, Comm::Connection::remote, removeClientStoreReference(), ClientHttpRequest::request, sc, Http::scGatewayTimeout, Ip::Address::setNoAddr(), startError(), and ClientHttpRequest::uri.

Referenced by processExpired(), and processMiss().

◆ processReplyAccess()

◆ processReplyAccessResult()

◆ purgeAllCached()

void clientReplyContext::purgeAllCached ( )

◆ purgeDoMissPurge()

◆ purgeDoPurgeGet()

◆ purgeDoPurgeHead()

◆ purgeFoundGet()

void clientReplyContext::purgeFoundGet ( StoreEntry newEntry)

◆ purgeFoundHead()

void clientReplyContext::purgeFoundHead ( StoreEntry newEntry)

Definition at line 970 of file client_side_reply.cc.

References purgeDoMissPurge(), and purgeFoundObject().

Referenced by created().

◆ purgeFoundObject()

◆ purgeRequest()

◆ purgeRequestFindObjectToPurge()

void clientReplyContext::purgeRequestFindObjectToPurge ( )

◆ pushStreamData()

◆ removeClientStoreReference()

◆ removeStoreReference()

void clientReplyContext::removeStoreReference ( store_client **  scp,
StoreEntry **  ep 

◆ replyStatus()

◆ restoreState()

◆ saveState()

◆ sendBodyTooLargeError()

◆ sendClientOldEntry()

void clientReplyContext::sendClientOldEntry ( )

◆ sendClientUpstreamResponse()

◆ sendMoreData()

◆ sendNotModified()

◆ sendNotModifiedOrPreconditionFailedError()

void clientReplyContext::sendNotModifiedOrPreconditionFailedError ( )

send 304 (Not Modified) or 412 (Precondition Failed) to client depending on request method

Definition at line 2025 of file client_side_reply.cc.

References http, HttpRequest::method, Http::METHOD_GET, Http::METHOD_HEAD, ClientHttpRequest::request, sendNotModified(), and sendPreconditionFailedError().

Referenced by processConditional().

◆ sendPreconditionFailedError()

◆ sendStreamError()

void clientReplyContext::sendStreamError ( StoreIOBuffer const &  result)

call clientWriteComplete so the client socket gets closed

We call into the stream, because we don't know that there is a client socket!

Definition at line 1918 of file client_side_reply.cc.

References ClientHttpRequest::client_stream, clientStreamCallback(), clientReplyContext::Flags::complete, dlink_node::data, debugs, StoreIOBuffer::error, StoreIOBuffer::flags, flags, HttpRequest::flags, dlink_list::head, http, NULL, ClientHttpRequest::request, and RequestFlags::streamError.

Referenced by sendMoreData().

◆ setReplyToError() [1/2]

void clientReplyContext::setReplyToError ( err_type  err,
Http::StatusCode  status,
const HttpRequestMethod method,
char const *  uri,
Ip::Address addr,
HttpRequest failedrequest,
const char *  unparsedrequest,
Auth::UserRequest::Pointer  auth_user_request 

Create an error in the store awaiting the client side to read it.

This may be better placed in the clientStream logic, but it has not been relocated there yet

Definition at line 104 of file client_side_reply.cc.

References ClientHttpRequest::al, clientBuildError(), http, and xstrdup.

Referenced by ConnStateData::abortChunkedRequestBody(), clientProcessRequest(), Http::One::Server::processParsedRequest(), ConnStateData::serveDelayedError(), and Http::One::Server::setReplyError().

◆ setReplyToError() [2/2]

◆ setReplyToReply()

◆ setReplyToStoreEntry()

◆ startCollapsingOn()

bool StoreClient::startCollapsingOn ( const StoreEntry e,
const bool  doingRevalidation 
whether the caller must collapse on the given entry Before returning true, updates common collapsing-related stats. See also: StoreEntry::hittingRequiresCollapsing().

Definition at line 65 of file store_client.cc.

References debugs, StoreEntry::hittingRequiresCollapsing(), StoreClient::loggingTags(), and StoreClient::onCollapsingPath().

Referenced by ICPState::confirmAndPrepHit(), UrnState::created(), identifyFoundObject(), processExpired(), and StoreClient::~StoreClient().

◆ startError()

◆ storeId()

const char* clientReplyContext::storeId ( ) const

◆ storeNotOKTransferDone()

◆ storeOKTransferDone()

int clientReplyContext::storeOKTransferDone ( ) const

◆ toCbdata()

void* clientReplyContext::toCbdata ( )

Definition at line 24 of file client_side_reply.h.

◆ traceReply()

◆ triggerInitialStoreRead()

void clientReplyContext::triggerInitialStoreRead ( )

Member Data Documentation

◆ CacheHit

void clientReplyContext::CacheHit

clientReplyContext::cacheHit Should only be called until the HTTP reply headers have been parsed. Normally this should be a single call, but it might take more than one. As soon as we have the headers, we hand off to clientSendMoreData, processExpired, or processMiss.

Definition at line 24 of file client_side_reply.h.

Referenced by doGetMoreData(), and purgeFoundObject().

◆ CBDATA_clientReplyContext

cbdata_type clientReplyContext::CBDATA_clientReplyContext = CBDATA_UNKNOWN

Definition at line 24 of file client_side_reply.h.

◆ collapsedRevalidation

CollapsedRevalidation clientReplyContext::collapsedRevalidation

Definition at line 153 of file client_side_reply.h.

Referenced by buildReplyHeader(), handleIMSReply(), and processExpired().

◆ deleting

bool clientReplyContext::deleting

Definition at line 145 of file client_side_reply.h.

Referenced by cacheHit(), handleIMSReply(), sendMoreData(), and ~clientReplyContext().

◆ flags

◆ HandleIMSReply

void clientReplyContext::HandleIMSReply

Definition at line 28 of file client_side_reply.h.

Referenced by processExpired(), and sendClientUpstreamResponse().

◆ headers_sz

int clientReplyContext::headers_sz

◆ holdingBuffer

StoreIOBuffer clientReplyContext::holdingBuffer

Definition at line 114 of file client_side_reply.h.

Referenced by sendMoreData().

◆ http

◆ lookingforstore

int clientReplyContext::lookingforstore

◆ lookup_type

const char* clientReplyContext::lookup_type

Definition at line 92 of file client_side_reply.h.

Referenced by buildReplyHeader(), and identifyFoundObject().

◆ old_entry

StoreEntry* clientReplyContext::old_entry

◆ old_etag

String clientReplyContext::old_etag

Definition at line 143 of file client_side_reply.h.

Referenced by restoreState(), and saveState().

◆ old_lastmod

time_t clientReplyContext::old_lastmod

Definition at line 142 of file client_side_reply.h.

Referenced by restoreState(), and saveState().

◆ old_reqsize

int clientReplyContext::old_reqsize

Definition at line 86 of file client_side_reply.h.

Referenced by restoreState(), saveState(), and sendClientUpstreamResponse().

◆ old_sc

store_client* clientReplyContext::old_sc

◆ ourNode

clientStreamNode* clientReplyContext::ourNode

Definition at line 102 of file client_side_reply.h.

Referenced by cacheHit(), clientGetMoreData(), and getNextNode().

◆ ProcessReplyAccessResult

void clientReplyContext::ProcessReplyAccessResult

Definition at line 117 of file client_side_reply.h.

Referenced by processReplyAccess().

◆ purgeStatus

Http::StatusCode clientReplyContext::purgeStatus

Definition at line 73 of file client_side_reply.h.

Referenced by purgeDoPurgeGet(), and purgeDoPurgeHead().

◆ reply

◆ reqofs

◆ reqsize

◆ sc

◆ SendMoreData

void clientReplyContext::SendMoreData

Accepts chunk of a http message in buf, parses prefix, filters headers and such, writes processed message to the message recipient

Definition at line 29 of file client_side_reply.h.

Referenced by clientGetMoreData(), clientReplyDetach(), traceReply(), and triggerInitialStoreRead().

◆ tempbuf

char clientReplyContext::tempbuf[HTTP_REQBUF_SZ]

◆ tempBuffer

StoreIOBuffer clientReplyContext::tempBuffer

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






Web Site Translations