#include <client_side.h>

Inheritance diagram for ConnStateData:
Collaboration diagram for ConnStateData:


class  PinnedIdleContext
 parameters for the async notePinnedConnectionBecameIdle() call More...

Public Types

typedef CbcPointer< AsyncJobPointer
typedef CbcPointer< BodyProducerPointer

Public Member Functions

 ConnStateData (const MasterXactionPointer &xact)
virtual ~ConnStateData ()
virtual void receivedFirstByte ()
 Update flags and timeout after the first byte received. More...
virtual bool handleReadData ()
virtual void afterClientRead ()
 processing to be done after a Comm::Read() More...
virtual void afterClientWrite (size_t)
 processing to sync state after a Comm::Write() More...
virtual void sendControlMsg (HttpControlMsg)
 called to send the 1xx message and notify the Source More...
virtual void doneWithControlMsg ()
bool clientParseRequests ()
 Traffic parsing. More...
void readNextRequest ()
void kick ()
 try to make progress on a transaction or read more I/O More...
bool isOpen () const
int64_t mayNeedToReadMoreBody () const
const Auth::UserRequest::PointergetAuth () const
void setAuth (const Auth::UserRequest::Pointer &aur, const char *cause)
bool transparent () const
const char * stoppedReceiving () const
 true if we stopped receiving the request More...
const char * stoppedSending () const
 true if we stopped sending the response More...
void stopReceiving (const char *error)
 note request receiving error and close as soon as we write the response More...
void stopSending (const char *error)
 note response sending error and close as soon as we read the request More...
void expectNoForwarding ()
 cleans up virgin request [body] forwarding state More...
BodyPipe::Pointer expectRequestBody (int64_t size)
virtual void noteMoreBodySpaceAvailable (BodyPipe::Pointer)=0
virtual void noteBodyConsumerAborted (BodyPipe::Pointer)=0
bool handleRequestBodyData ()
void notePinnedConnectionBecameIdle (PinnedIdleContext pic)
 Called when a pinned connection becomes available for forwarding the next request. More...
void pinBusyConnection (const Comm::ConnectionPointer &pinServerConn, const HttpRequest::Pointer &request)
void unpinConnection (const bool andClose)
 Undo pinConnection() and, optionally, close the pinned connection. More...
Comm::ConnectionPointer borrowPinnedConnection (HttpRequest *request, const CachePeer *aPeer)
 Returns validated pinnned server connection (and stops its monitoring). More...
const Comm::ConnectionPointer validatePinnedConnection (HttpRequest *request, const CachePeer *peer)
CachePeerpinnedPeer () const
bool pinnedAuth () const
virtual void notePeerConnection (Comm::ConnectionPointer)
 called just before a FwdState-dispatched job starts using connection More...
virtual void clientPinnedConnectionClosed (const CommCloseCbParams &io)
 Our close handler called by Comm when the pinned connection is closed. More...
void clientReadFtpData (const CommIoCbParams &io)
void connStateClosed (const CommCloseCbParams &io)
void requestTimeout (const CommTimeoutCbParams &params)
virtual void start ()
 called by AsyncStart; do not call directly More...
virtual bool doneAll () const
 whether positive goal has been reached More...
virtual void swanSong ()
void quitAfterError (HttpRequest *request)
void stopPinnedConnectionMonitoring ()
 The caller assumes responsibility for connection closure detection. More...
void postHttpsAccept ()
 the second part of old httpsAccept, waiting for future HttpsServer home More...
void startPeekAndSplice ()
 Initializes and starts a peek-and-splice negotiation with the SSL client. More...
void doPeekAndSpliceStep ()
void httpsPeeked (PinnedIdleContext pic)
 called by FwdState when it is done bumping the server More...
bool splice ()
 Splice a bumped client connection on peek-and-splice mode. More...
void getSslContextStart ()
 Start to create dynamic Security::ContextPointer for host or uses static port SSL context. More...
void getSslContextDone (Security::ContextPointer &)
 finish configuring the newly created SSL context" More...
void sslCrtdHandleReply (const Helper::Reply &reply)
 Proccess response from ssl_crtd. More...
void switchToHttps (HttpRequest *request, Ssl::BumpMode bumpServerMode)
void parseTlsHandshake ()
bool switchedToHttps () const
Ssl::ServerBumpserverBump ()
void setServerBump (Ssl::ServerBump *srvBump)
const SBufsslCommonName () const
void resetSslCommonName (const char *name)
const SBuftlsClientSni () const
void buildSslCertGenerationParams (Ssl::CertificateProperties &certProperties)
bool serveDelayedError (Http::Stream *)
virtual bool writeControlMsgAndCall (HttpReply *rep, AsyncCall::Pointer &call)=0
 handle a control message received by context from a peer and call back More...
virtual void handleReply (HttpReply *header, StoreIOBuffer receivedData)=0
void consumeInput (const size_t byteCount)
 remove no longer needed leading bytes from the input buffer More...
Http::StreamabortRequestParsing (const char *const errUri)
 stop parsing the request and create context for relaying error info More...
bool fakeAConnectRequest (const char *reason, const SBuf &payload)
bool initiateTunneledRequest (HttpRequest::Pointer const &cause, Http::MethodType const method, const char *reason, const SBuf &payload)
 generates and sends to tunnel.cc a fake request with a given payload More...
bool mayTunnelUnsupportedProto ()
 whether tunneling of unsupported protocol is allowed for this connection More...
ClientHttpRequestbuildFakeRequest (Http::MethodType const method, SBuf &useHost, unsigned short usePort, const SBuf &payload)
 build a fake http request More...
virtual void startShutdown ()
virtual void endingShutdown ()
NotePairs::Pointer notes ()
bool hasNotes () const
void readSomeData ()
 maybe grow the inBuf and schedule Comm::Read() More...
bool reading () const
 whether Comm::Read() is scheduled More...
void stopReading ()
 cancels Comm::Read() if it is scheduled More...
virtual void writeSomeData ()
 maybe find some data to send and schedule a Comm::Write() More...
void write (MemBuf *mb)
 schedule some data for a Comm::Write() More...
void write (char *buf, int len)
 schedule some data for a Comm::Write() More...
bool writing () const
 whether Comm::Write() is scheduled More...
void maybeMakeSpaceAvailable ()
 grows the available read buffer space (if possible) More...
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
void wroteControlMsg (const CommIoCbParams &)
 callback to handle Comm::Write completion More...

Static Public Member Functions

static void sslCrtdHandleReplyWrapper (void *data, const Helper::Reply &reply)
 Callback function. It is called when squid receive message from ssl_crtd. More...
static Pointer Start (AsyncJob *job)
 starts a freshly created job (i.e., makes the job asynchronous) More...

Public Attributes

 parses HTTP/1.1 chunked request body More...
Ip::Address log_addr
struct {
   bool   readMore
 needs comm_read (for this request or new requests) More...
   bool   swanSang
struct {
   Comm::ConnectionPointer   serverConnection
   char *   host
   int   port
   bool   pinned
   bool   auth
   bool   reading
 we are monitoring for peer connection closure More...
   bool   zeroReply
 server closed w/o response (ERR_ZERO_SIZE_OBJECT) More...
   CachePeer *   peer
   AsyncCall::Pointer   readHandler
 detects serverConnection closure More...
   AsyncCall::Pointer   closeHandler
Ssl::BumpMode sslBumpMode
 ssl_bump decision (Ssl::bumpEnd if n/a). More...
Security::HandshakeParser tlsParser
SBuf preservedClientData
Comm::ConnectionPointer clientConnection
AnyP::ProtocolVersion transferProtocol
SBuf inBuf
 read I/O buffer for the client connection More...
bool receivedFirstByte_
 true if at least one byte received on this connection More...
Pipeline pipeline
 set of requests waiting to be serviced More...
AsyncCall::Pointer cbControlMsgSent
 Call to schedule when the control msg has been sent. More...

Protected Member Functions

void startDechunkingRequest ()
 initialize dechunking state More...
void finishDechunkingRequest (bool withSuccess)
 put parsed content into input buffer and clean up More...
void abortChunkedRequestBody (const err_type error)
 quit on errors related to chunked request body handling More...
err_type handleChunkedRequestBody ()
 parses available chunked encoded body bytes, checks size, returns errors More...
void startPinnedConnectionMonitoring ()
void clientPinnedConnectionRead (const CommIoCbParams &io)
bool handleIdleClientPinnedTlsRead ()
virtual Http::StreamparseOneRequest ()=0
virtual void processParsedRequest (Http::StreamPointer &)=0
 start processing a freshly parsed request More...
virtual int pipelinePrefetchMax () const
 returning N allows a pipeline of 1+N requests (see pipeline_prefetch) More...
virtual time_t idleTimeout () const =0
 timeout to use when waiting for the next request More...
void whenClientIpKnown ()
void doClientRead (const CommIoCbParams &io)
void clientWriteDone (const CommIoCbParams &io)
void deleteThis (const char *aReason)
void mustStop (const char *aReason)
bool done () const
 the job is destroyed in callEnd() when done() More...
virtual const char * status () const
 internal cleanup; do not call directly More...
void stopProducingFor (RefCount< BodyPipe > &, bool atEof)

Protected Attributes

BodyPipe::Pointer bodyPipe
 set when we are reading request body More...
AsyncCall::Pointer reader
 set when we are reading More...
AsyncCall::Pointer writer
 set when we are writing More...
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 Types

typedef void(RegisteredRunner::* Method )()
 a pointer to one of the above notification methods More...

Private Member Functions

virtual bool connFinishedWithConn (int size)
 ?? More...
virtual void checkLogging ()
 Log the current [attempt at] transaction if nobody else will. More...
void clientAfterReadingRequests ()
bool concurrentRequestQueueFilled () const
void pinConnection (const Comm::ConnectionPointer &pinServerConn, const HttpRequest &request)
 Forward future client requests using the given server connection. More...
bool proxyProtocolValidateClient ()
bool parseProxyProtocolHeader ()
bool parseProxy1p0 ()
 parse the PROXY/1.0 protocol header from the connection read buffer More...
bool parseProxy2p0 ()
 parse the PROXY/2.0 protocol header from the connection read buffer More...
bool proxyProtocolError (const char *reason)
Security::ContextPointer getTlsContextFromCache (const SBuf &cacheKey, const Ssl::CertificateProperties &certProperties)
void storeTlsContextToCache (const SBuf &cacheKey, Security::ContextPointer &ctx)
void registerRunner ()
void unregisterRunner ()
 unregisters self; safe to call multiple times More...
virtual void finalizeConfig ()
virtual void claimMemoryNeeds ()
virtual void useConfig ()
virtual void startReconfigure ()
virtual void syncConfig ()
virtual void finishShutdown ()
 Meant for cleanup of services needed by the already destroyed objects. More...

Private Attributes

bool needProxyProtocolHeader_
 whether PROXY protocol header is still expected More...
Auth::UserRequest::Pointer auth_
 some user details that can be used to perform authentication on this connection More...
Http1::RequestParserPointer parser_
 the parser state for current HTTP/1.x input buffer processing More...
bool switchedToHttps_
bool parsingTlsHandshake
 whether we are getting/parsing TLS Hello bytes More...
String sslConnectHostOrIp
 The SSL server host name appears in CONNECT request or the server ip address for the intercepted requests. More...
SBuf sslCommonName_
 CN name for SSL certificate generation. More...
SBuf tlsClientSni_
 TLS client delivered SNI value. Empty string if none has been received. More...
SBuf sslBumpCertKey
 Key to use to store/retrieve generated certificate. More...
 HTTPS server cert. fetching state for bump-ssl-server-first. More...
Ssl::CertSignAlgorithm signAlgorithm
 The signing algorithm to use. More...
const char * stoppedSending_
 the reason why we no longer write the response or nil More...
const char * stoppedReceiving_
 the reason why we no longer read the request or nil More...
NotePairs::Pointer theNotes

Detailed Description

Legacy Server code managing a connection to a client.

NP: presents AsyncJob API but does not operate autonomously as a Job. So Must() is not safe to use.

Multiple requests (up to pipeline_prefetch) can be pipelined. This object is responsible for managing which one is currently being fulfilled and what happens to the queue if the current one causes the client connection to be closed early.

Act as a manager for the client connection and passes data in buffer to a Parser relevant to the state (message headers vs body) that is being processed.

Performs HTTP message processing to kick off the actual HTTP request handling objects (Http::Stream, ClientHttpRequest, HttpRequest).

Performs SSL-Bump processing for switching between HTTP and HTTPS protocols.

To terminate a ConnStateData close() the client Comm::Connection it is managing, or for graceful half-close use the stopReceiving() or stopSending() methods.

Definition at line 73 of file client_side.h.

Member Typedef Documentation

typedef void(RegisteredRunner::* RegisteredRunner::Method)()

Definition at line 90 of file RunnersRegistry.h.

Definition at line 25 of file BodyPipe.h.

Definition at line 34 of file AsyncJob.h.

Constructor & Destructor Documentation

ConnStateData::~ConnStateData ( )

Member Function Documentation

void ConnStateData::afterClientWrite ( size_t  )
Comm::ConnectionPointer ConnStateData::borrowPinnedConnection ( HttpRequest request,
const CachePeer aPeer 
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 ConnStateData::checkLogging ( )
virtual void RegisteredRunner::claimMemoryNeeds ( )

Called after finalizeConfig(). Meant for announcing memory reservations before memory is allocated.

Reimplemented in MemStoreRr, and IpcIoRr.

Definition at line 51 of file RunnersRegistry.h.

Referenced by StartUsingConfig().

void ConnStateData::clientAfterReadingRequests ( )
bool ConnStateData::clientParseRequests ( )

Attempt to parse one or more requests from the input buffer. Returns true after completing parsing of at least one request [header]. That includes cases where parsing ended with an error (e.g., a huge request).

Definition at line 2093 of file client_side.cc.

References bodyPipe, Server::clientConnection, clientLifetimeTimeout, commCbCall(), commSetConnTimeout(), concurrentRequestQueueFilled(), Config, debugs, flags, HERE(), Server::inBuf, SBuf::isEmpty(), SBuf::length(), SquidConfig::lifetime, SquidConfig::maxRequestHeaderSize, Must, needProxyProtocolHeader_, parseOneRequest(), parseProxyProtocolHeader(), pinning, processParsedRequest(), SquidConfig::Timeout, and whenClientIpKnown().

Referenced by afterClientRead(), and kick().

void ConnStateData::clientPinnedConnectionClosed ( const CommCloseCbParams io)
void ConnStateData::clientPinnedConnectionRead ( const CommIoCbParams io)

Our read handler called by Comm when the server either closes an idle pinned connection or perhaps unexpectedly sends something on that idle (from Squid p.o.v.) connection.

Definition at line 4049 of file client_side.cc.

References Server::clientConnection, Comm::Connection::close(), CommCommonCbParams::conn, debugs, Pipeline::empty(), Comm::ERR_CLOSING, CommCommonCbParams::flag, handleIdleClientPinnedTlsRead(), Must, NULL, pinning, Server::pipeline, and CommIoCbParams::size.

Referenced by startPinnedConnectionMonitoring().

void ConnStateData::clientReadFtpData ( const CommIoCbParams io)
void Server::clientWriteDone ( const CommIoCbParams io)

callback handling the Comm::Write completion

Will call afterClientWrite(size_t) to sync the I/O state. Then writeSomeData() to initiate any followup writes that could be immediately done.

Definition at line 186 of file Server.cc.

References Server::afterClientWrite(), Server::clientConnection, CommCommonCbParams::conn, debugs, Comm::ERR_CLOSING, Comm::Connection::fd, CommCommonCbParams::flag, Pipeline::front(), Comm::IsConnOpen(), Must, Server::pipeline, CommIoCbParams::size, Server::writer, and Server::writeSomeData().

Referenced by Server::write().

bool ConnStateData::concurrentRequestQueueFilled ( ) const

Limit the number of concurrent requests.

true when there are available position(s) in the pipeline queue for another request.
false when the pipeline queue is full or disabled.

Definition at line 1792 of file client_side.cc.

References Ssl::bumpSplice, Server::clientConnection, Pipeline::count(), debugs, Server::pipeline, pipelinePrefetchMax(), sslBumpMode, and transparent().

Referenced by clientParseRequests().

bool ConnStateData::connFinishedWithConn ( int  size)
void ConnStateData::connStateClosed ( const CommCloseCbParams io)

Definition at line 496 of file client_side.cc.

References AsyncJob::deleteThis().

Referenced by start().

void ConnStateData::consumeInput ( const size_t  byteCount)

Definition at line 1449 of file client_side.cc.

References assert, SBuf::consume(), debugs, Server::inBuf, and SBuf::length().

Referenced by handleRequestBodyData(), and parseHttpRequest().

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

virtual bool ConnStateData::doneAll ( ) const

Reimplemented from Server.

Definition at line 212 of file client_side.h.

References AsyncJob::doneAll().

void ConnStateData::doneWithControlMsg ( )
void ConnStateData::doPeekAndSpliceStep ( )

Called when a peek-and-splice step finished. For example after server SSL certificates received and fake server SSL certificates generated

Definition at line 3345 of file client_side.cc.

References assert, BIO_get_data(), Server::clientConnection, clientNegotiateSSL(), COMM_SELECT_WRITE, debugs, Comm::Connection::fd, fd_table, Ssl::ClientBio::hold(), Comm::SetSelect(), and switchedToHttps_.

Referenced by getSslContextStart(), and sslCrtdHandleReply().

void ConnStateData::endingShutdown ( )

Called after shutdown_lifetime grace period ends and before stopping the main loop. At least one main loop iteration is guaranteed after this call. Meant for cleanup and state saving that may require other modules.

Reimplemented from RegisteredRunner.

Definition at line 1040 of file client_side.cc.

References Server::clientConnection, Comm::Connection::close(), and Comm::IsConnOpen().

Referenced by startShutdown().

void ConnStateData::expectNoForwarding ( )
BodyPipe::Pointer ConnStateData::expectRequestBody ( int64_t  size)

Definition at line 3769 of file client_side.cc.

References bodyPipe, BodyPipe::setBodySize(), and startDechunkingRequest().

Referenced by clientProcessRequest().

bool ConnStateData::fakeAConnectRequest ( const char *  reason,
const SBuf payload 
virtual void RegisteredRunner::finalizeConfig ( )

Called after parsing squid.conf. Meant for setting configuration options that depend on other configuration options and were not explicitly configured.

Reimplemented in sslBumpCfgRr, and MemStoreRr.

Definition at line 47 of file RunnersRegistry.h.

Referenced by SquidMain().

void ConnStateData::finishDechunkingRequest ( bool  withSuccess)
virtual void RegisteredRunner::finishShutdown ( )

Definition at line 87 of file RunnersRegistry.h.

Referenced by RunRegistered(), SquidShutdown(), testRock::tearDown(), and watch_child().

const Auth::UserRequest::Pointer& ConnStateData::getAuth ( ) const

Fetch the user details for connection based authentication NOTE: this is ONLY connection based because NTLM and Negotiate is against HTTP spec.

Definition at line 114 of file client_side.h.

References auth_.

Referenced by Auth::UserRequest::authenticate(), AuthenticateAcl(), authTryGetUser(), buildFakeRequest(), ClientHttpRequest::calloutsError(), ClientRequestContext::clientAccessCheckDone(), clientProcessRequest(), constructHelperQuery(), and ClientRequestContext::hostHeaderVerifyFailed().

Security::ContextPointer ConnStateData::getTlsContextFromCache ( const SBuf cacheKey,
const Ssl::CertificateProperties certProperties 
bool ConnStateData::handleIdleClientPinnedTlsRead ( )

Handles a ready-for-reading TLS squid-to-server connection that we thought was idle.

false if and only if the connection should be closed.

Definition at line 4008 of file client_side.cc.

References buf, DBG_IMPORTANT, debugs, error(), fd_table, Must, pinning, and startPinnedConnectionMonitoring().

Referenced by clientPinnedConnectionRead().

bool ConnStateData::handleReadData ( )

called when new request data has been read from the socket

Return values
falsecalled comm_close or setReplyToError (the caller should bail)
truewe did not call comm_close or setReplyToError

Implements Server.

Definition at line 2198 of file client_side.cc.

References bodyPipe, handleRequestBodyData(), and NULL.

virtual void ConnStateData::handleReply ( HttpReply header,
StoreIOBuffer  receivedData 
pure virtual

ClientStream calls this to supply response header (once) and data for the current Http::Stream.

Implemented in Ftp::Server, and Http::One::Server.

Referenced by clientSocketRecipient().

bool ConnStateData::handleRequestBodyData ( )

called when new request body data has been buffered in inBuf may close the connection if we were closing and piped everything out

Return values
falsecalled comm_close or setReplyToError (the caller should bail)
truewe did not call comm_close or setReplyToError

Definition at line 2214 of file client_side.cc.

References abortChunkedRequestBody(), assert, bodyParser, bodyPipe, SBuf::c_str(), Server::clientConnection, Comm::Connection::close(), consumeInput(), debugs, error(), handleChunkedRequestBody(), HERE(), Server::inBuf, SBuf::length(), BodyPipe::mayNeedMoreData(), NULL, BodyPipe::putMoreData(), and stoppedSending().

Referenced by clientProcessRequest(), and handleReadData().

bool ConnStateData::hasNotes ( ) const

Definition at line 320 of file client_side.h.

References NotePairs::empty(), and theNotes.

virtual time_t ConnStateData::idleTimeout ( ) const
protectedpure virtual

Implemented in Ftp::Server, and Http::One::Server.

Referenced by readNextRequest().

void ConnStateData::kick ( )
We are done with the response, and we are either still receiving request body (early response!) or have already stopped receiving anything.

If we are still receiving, then clientParseRequest() below will fail. (XXX: but then we will call readNextRequest() which may succeed and execute a smuggled request as we are not done with the current request).

If we stopped because we got everything, then try the next request.

If we stopped receiving because of an error, then close now to avoid getting stuck and to prevent accidental request smuggling.

Attempt to parse a request from the request buffer. If we've been fed a pipelined request it may already be in our read buffer.
This needs to fall through - if we're unlucky and parse the last request from our read buffer we may never re-register for another client read.
Either we need to kick-start another read or, if we have a half-closed connection, kill it after the last request. This saves waiting for half-closed connections to finished being half-closed AND then, sometimes, spending "Timeout" time in the keepalive "Waiting for next request" state.
At this point we either have a parsed request (which we've kicked off the processing for) or not. If we have a deferred request (parsed but deferred for pipeling processing reasons) then look at processing it. If not, simply kickstart another read.

Definition at line 892 of file client_side.cc.

References Server::clientConnection, clientParseRequests(), ClientSocketContextPushDeferredIfNeeded(), Comm::Connection::close(), commIsHalfClosed(), DBG_IMPORTANT, debugs, Pipeline::empty(), Comm::Connection::fd, flags, Pipeline::front(), Comm::IsConnOpen(), MYNAME, pinning, Server::pipeline, readNextRequest(), and stoppedReceiving().

Referenced by notePinnedConnectionBecameIdle(), and Http::Stream::writeComplete().

void Server::maybeMakeSpaceAvailable ( )

Prepare inBuf for I/O. This method balances several conflicting desires:

  1. Do not read too few bytes at a time.
  2. Do not waste too much buffer space.
  3. Do not [re]allocate or memmove the buffer too much.
  4. Obey Config.maxRequestBufferSize limit.

Definition at line 70 of file Server.cc.

References SBufReservationRequirements::allowShared, CLIENT_REQ_BUF_SZ, Config, debugs, SBufReservationRequirements::idealSpace, Server::inBuf, SBufReservationRequirements::maxCapacity, SquidConfig::maxRequestBufferSize, SBufReservationRequirements::minSpace, SBuf::reserve(), and SBuf::spaceSize().

Referenced by Server::doClientRead().

int64_t ConnStateData::mayNeedToReadMoreBody ( ) const

number of body bytes we need to comm_read for the "current" request

Return values
0We do not need to read any [more] body bytes
negativeMay need more but do not know how many; could be zero!
positiveNeed to read exactly that many more body bytes

Definition at line 3780 of file client_side.cc.

References bodyPipe, BodyPipe::bodySizeKnown(), Server::inBuf, SBuf::length(), and BodyPipe::unproducedSize().

Referenced by clientAfterReadingRequests(), and stopSending().

bool ConnStateData::mayTunnelUnsupportedProto ( )
void ConnStateData::noteBodyConsumerAborted ( BodyPipe::Pointer  )
pure virtual
virtual void ConnStateData::noteMoreBodySpaceAvailable ( BodyPipe::Pointer  )
pure virtual

Implements BodyProducer.

Implemented in Ftp::Server, and Http::One::Server.

virtual void ConnStateData::notePeerConnection ( Comm::ConnectionPointer  )

Reimplemented in Ftp::Server.

Definition at line 200 of file client_side.h.

Referenced by FwdState::connectedToPeer().

NotePairs::Pointer ConnStateData::notes ( )
existing non-empty connection annotations, creates and returns empty annotations otherwise

Definition at line 4186 of file client_side.cc.

References theNotes.

Referenced by UpdateRequestNotes().

virtual Http::Stream* ConnStateData::parseOneRequest ( )
protectedpure virtual

parse input buffer prefix into a single transfer protocol request return NULL to request more header bytes (after checking any limits) use abortRequestParsing() to handle parsing errors w/o creating request

Implemented in Ftp::Server, and Http::One::Server.

Referenced by clientParseRequests().

bool ConnStateData::parseProxyProtocolHeader ( )

Test the connection read buffer for PROXY protocol header. Version 1 and 2 header currently supported.

Definition at line 1870 of file client_side.cc.

References Server::inBuf, SBuf::length(), parseProxy1p0(), parseProxy2p0(), Proxy1p0magic, Proxy2p0magic, proxyProtocolError(), and SBuf::startsWith().

Referenced by clientParseRequests().

void ConnStateData::pinBusyConnection ( const Comm::ConnectionPointer pinServerConn,
const HttpRequest::Pointer request 

Forward future client requests using the given to-server connection. The connection is still being used by the current client request.

Definition at line 3920 of file client_side.cc.

References pinConnection().

bool ConnStateData::pinnedAuth ( ) const

Definition at line 197 of file client_side.h.

References pinning.

Referenced by FwdState::connectStart().

CachePeer* ConnStateData::pinnedPeer ( ) const

returts the pinned CachePeer if exists, NULL otherwise

Definition at line 196 of file client_side.h.

References pinning.

Referenced by PeerSelector::selectPinned().

int ConnStateData::pipelinePrefetchMax ( ) const

Reimplemented in Ftp::Server.

Definition at line 1778 of file client_side.cc.

References Config, pinning, and SquidConfig::pipeline_max_prefetch.

Referenced by concurrentRequestQueueFilled().

virtual void ConnStateData::processParsedRequest ( Http::StreamPointer )
protectedpure virtual

Implemented in Ftp::Server, and Http::One::Server.

Referenced by clientParseRequests().

bool ConnStateData::proxyProtocolError ( const char *  msg)

Perform cleanup on PROXY protocol errors. If header parsing hits a fatal error terminate the connection, otherwise wait for more data.

Definition at line 1843 of file client_side.cc.

References Server::clientConnection, DBG_IMPORTANT, debugs, and AsyncJob::mustStop().

Referenced by parseProxy1p0(), parseProxy2p0(), parseProxyProtocolHeader(), and proxyProtocolValidateClient().

bool ConnStateData::proxyProtocolValidateClient ( )

Perform proxy_protocol_access ACL tests on the client which connected to PROXY protocol port to see if we trust the sender enough to accept their PROXY header claim.

Definition at line 1821 of file client_side.cc.

References SquidConfig::accessList, allow_t::allowed(), Server::clientConnection, Config, ACLFilledChecklist::conn(), ACLChecklist::fastCheck(), Comm::Connection::local, ACLFilledChecklist::my_addr, NULL, SquidConfig::proxyProtocol, proxyProtocolError(), Comm::Connection::remote, Comm::Connection::rfc931, and ACLFilledChecklist::src_addr.

Referenced by start().

void ConnStateData::quitAfterError ( HttpRequest request)

Changes state so that we close the connection and quit after serving the client-side-detected error response instead of getting stuck.

Definition at line 1471 of file client_side.cc.

References Server::clientConnection, debugs, HttpRequest::flags, flags, HERE(), and RequestFlags::proxyKeepalive.

Referenced by clientProcessRequest(), and serveDelayedError().

bool Server::reading ( ) const

Definition at line 57 of file Server.h.

References NULL, and Server::reader.

Referenced by Server::doClientRead(), Server::readSomeData(), and Server::stopReading().

void ConnStateData::readNextRequest ( )

Set the timeout BEFORE calling readSomeData().

Please don't do anything with the FD past here!

Definition at line 852 of file client_side.cc.

References Server::clientConnection, commSetConnTimeout(), debugs, Comm::Connection::fd, fd_note(), HERE(), idleTimeout(), JobCallback, Server::readSomeData(), requestTimeout(), and Comm::Connection::timeLeft().

Referenced by kick().

void ConnStateData::receivedFirstByte ( )
void IndependentRunner::registerRunner ( )

Definition at line 104 of file RunnersRegistry.cc.

References FindRunners(), and RegisterRunner_().

Referenced by ConnStateData(), and IdleConnList::IdleConnList().

void ConnStateData::resetSslCommonName ( const char *  name)

Definition at line 261 of file client_side.h.

References sslCommonName_.

Referenced by parseTlsHandshake(), and switchToHttps().

bool ConnStateData::serveDelayedError ( Http::Stream context)

Called when the client sends the first request on a bumped connection. Returns false if no [delayed] error should be written to the client. Otherwise, writes the error to the client and returns true. Also checks for SQUID_X509_V_ERR_DOMAIN_MISMATCH on bumped requests.

Definition at line 1483 of file client_side.cc.

References ACLFilledChecklist::al, ClientHttpRequest::al, allow_t::allowed(), assert, SquidConfig::cert_error, Ssl::checkX509ServerValidity(), Server::clientConnection, Config, dash_str, clientStreamNode::data, debugs, ErrorState::detail, HttpRequest::detailError(), Ssl::ServerBump::entry, ERR_SECURE_CONNECT_FAIL, HttpRequest::errDetail, HttpRequest::errType, ACLChecklist::fastCheck(), Http::Stream::getClientReplyContext(), RefCount< C >::getRaw(), HttpRequest::hier, URL::host(), Http::Stream::http, HTTPMSGLOCK(), StoreEntry::isEmpty(), ClientHttpRequest::log_uri, HttpRequest::method, NULL, ClientHttpRequest::Out::offset, ClientHttpRequest::out, Http::Stream::pullData(), quitAfterError(), Comm::Connection::remote, Ssl::ServerBump::request, ClientHttpRequest::request, AccessLogEntry::request, request(), Http::scServiceUnavailable, Ssl::ServerBump::serverCert, clientReplyContext::setReplyToError(), clientReplyContext::setReplyToStoreEntry(), SQUID_X509_V_ERR_DOMAIN_MISMATCH, ErrorState::src_addr, SquidConfig::ssl_client, ACLFilledChecklist::sslErrors, sslServerBump, ACLFilledChecklist::syncAle(), ClientHttpRequest::uri, and HttpRequest::url.

Referenced by clientProcessRequest().

void ConnStateData::setAuth ( const Auth::UserRequest::Pointer aur,
const char *  cause 

Set the user details for connection-based authentication to use from now until connection closure.

Any change to existing credentials shows that something invalid has happened. Such as:

  • NTLM/Negotiate auth was violated by the per-request headers missing a revalidation token
  • NTLM/Negotiate auth was violated by the per-request headers being for another user
  • SSL-Bump CONNECT tunnel with persistent credentials has ended

Definition at line 503 of file client_side.cc.

References auth_, Server::clientConnection, comm_reset_close(), debugs, NULL, Auth::UserRequest::releaseAuthServer(), and stopReceiving().

Referenced by Auth::UserRequest::authenticate(), ProxyAuthLookup::LookupDone(), ClientHttpRequest::sslBumpEstablish(), and swanSong().

void ConnStateData::setServerBump ( Ssl::ServerBump srvBump)

Definition at line 254 of file client_side.h.

References assert, and sslServerBump.

Referenced by ClientHttpRequest::doCallouts().

const SBuf& ConnStateData::sslCommonName ( ) const

Definition at line 260 of file client_side.h.

References sslCommonName_.

void ConnStateData::sslCrtdHandleReplyWrapper ( void *  data,
const Helper::Reply reply 

Definition at line 2850 of file client_side.cc.

References sslCrtdHandleReply().

Referenced by getSslContextStart().

void ConnStateData::startDechunkingRequest ( )

Definition at line 3828 of file client_side.cc.

References assert, bodyParser, bodyPipe, debugs, HERE(), Must, NULL, and BodyPipe::status().

Referenced by expectRequestBody().

void ConnStateData::startPinnedConnectionMonitoring ( )

[re]start monitoring pinned connection for peer closures so that we can propagate them to an idle client pinned to that peer

Definition at line 3986 of file client_side.cc.

References clientPinnedConnectionRead(), JobCallback, NULL, pinning, and Comm::Read().

Referenced by handleIdleClientPinnedTlsRead(), and notePinnedConnectionBecameIdle().

virtual void RegisteredRunner::startReconfigure ( )

Called after receiving a reconfigure request and before parsing squid.conf. Meant for modules that need to prepare for their configuration being changed [outside their control]. The changes end with the syncConfig() event.

Reimplemented in Dns::ConfigRr.

Definition at line 63 of file RunnersRegistry.h.

Referenced by mainReconfigureStart().

void ConnStateData::startShutdown ( )

Called after receiving a shutdown request and before stopping the main loop. At least one main loop iteration is guaranteed after this call. Meant for cleanup and state saving that may require other modules.

Reimplemented from RegisteredRunner.

Definition at line 1029 of file client_side.cc.

References Pipeline::empty(), endingShutdown(), and Server::pipeline.

const char* ConnStateData::stoppedReceiving ( ) const

Definition at line 149 of file client_side.h.

References stoppedReceiving_.

Referenced by kick(), stopReceiving(), and stopSending().

const char* ConnStateData::stoppedSending ( ) const

Definition at line 151 of file client_side.h.

References stoppedSending_.

Referenced by handleRequestBodyData(), stopReceiving(), and stopSending().

void ConnStateData::stopPinnedConnectionMonitoring ( )

Definition at line 3998 of file client_side.cc.

References NULL, pinning, and Comm::ReadCancel().

Referenced by borrowPinnedConnection(), and unpinConnection().

void BodyProducer::stopProducingFor ( RefCount< BodyPipe > &  p,
bool  atEof 
void Server::stopReading ( )
void ConnStateData::stopReceiving ( const char *  error)
void ConnStateData::storeTlsContextToCache ( const SBuf cacheKey,
Security::ContextPointer ctx 

Attempts to add a given TLS context to the cache, replacing the old same-key context, if any

Definition at line 2995 of file client_side.cc.

References LruMap< Key, EntryValue, EntryCost >::add(), Server::clientConnection, Comm::Connection::fd, fd_table, Ssl::GlobalContextStorage::getLocalStorage(), port, and Ssl::TheGlobalContextStorage.

Referenced by getSslContextStart(), and sslCrtdHandleReply().

bool ConnStateData::switchedToHttps ( ) const
virtual void RegisteredRunner::syncConfig ( )

Called after parsing squid.conf during reconfiguration. Meant for adjusting the module state based on configuration changes.

Reimplemented in PeerPoolMgrsRr, and Auth::CredentialCacheRr.

Definition at line 67 of file RunnersRegistry.h.

Referenced by mainReconfigureFinish().

const SBuf& ConnStateData::tlsClientSni ( ) const

Definition at line 262 of file client_side.h.

References tlsClientSni_.

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited
bool ConnStateData::transparent ( ) const
void IndependentRunner::unregisterRunner ( )

Definition at line 96 of file RunnersRegistry.cc.

References FindRunners().

Referenced by IndependentRunner::~IndependentRunner().

virtual void RegisteredRunner::useConfig ( )

Called after claimMemoryNeeds(). Meant for activating modules and features using a finalized configuration with known memory requirements.

Reimplemented in MemStoreRr, SharedSessionCacheRr, TransientsRr, PeerPoolMgrsRr, ClientDbRr, SharedMemPagesRr, and Ipc::Mem::RegisteredRunner.

Definition at line 56 of file RunnersRegistry.h.

Referenced by StartUsingConfig().

const Comm::ConnectionPointer ConnStateData::validatePinnedConnection ( HttpRequest request,
const CachePeer peer 

Checks if there is pinning info if it is valid. It can close the server side connection if pinned info is not valid.

requestif it is not NULL also checks if the pinning info refers to the request client side HttpRequest
CachePeerif it is not NULL also check if the CachePeer is the pinning CachePeer
The details of the server side connection (may be closed if failures were present).

Definition at line 4078 of file client_side.cc.

References cbdataReferenceValid(), debugs, HERE(), URL::host(), Comm::IsConnOpen(), pinning, URL::port(), unpinConnection(), and HttpRequest::url.

Referenced by borrowPinnedConnection(), and PeerSelector::selectPinned().

void Server::write ( MemBuf mb)
void Server::write ( char *  buf,
int  len 
virtual bool ConnStateData::writeControlMsgAndCall ( HttpReply rep,
AsyncCall::Pointer call 
pure virtual

Implemented in Ftp::Server, and Http::One::Server.

Referenced by sendControlMsg().

virtual void Server::writeSomeData ( )

Definition at line 66 of file Server.h.

Referenced by Server::clientWriteDone().

bool Server::writing ( ) const

Definition at line 86 of file Server.h.

References NULL, and Server::writer.

void HttpControlMsgSink::wroteControlMsg ( const CommIoCbParams params)

Member Data Documentation

bool ConnStateData::auth

Definition at line 138 of file client_side.h.

Referenced by clientCheckPinning().

Auth::UserRequest::Pointer ConnStateData::auth_

Definition at line 388 of file client_side.h.

Referenced by getAuth(), and setAuth().

AsyncCall::Pointer HttpControlMsgSink::cbControlMsgSent
Comm::ConnectionPointer Server::clientConnection

Definition at line 97 of file Server.h.

Referenced by abortChunkedRequestBody(), abortRequestParsing(), afterClientRead(), Format::Format::assemble(), Auth::UserRequest::authenticate(), buildFakeRequest(), buildSslCertGenerationParams(), ClientHttpRequest::calloutsError(), IdentLookup::checkForAsync(), ClientRequestContext::clientAccessCheckDone(), clientAclChecklistFill(), clientAfterReadingRequests(), ClientHttpRequest::ClientHttpRequest(), clientIdentDone(), clientNegotiateSSL(), clientParseRequests(), clientPinnedConnectionClosed(), clientPinnedConnectionRead(), clientProcessRequest(), clientProcessRequestFinished(), ClientRequestContext::clientRedirectDone(), ClientSocketContextPushDeferredIfNeeded(), clientSocketRecipient(), clientTunnelOnError(), Server::clientWriteDone(), concurrentRequestQueueFilled(), connFinishedWithConn(), constructHelperQuery(), ClientHttpRequest::doCallouts(), Server::doClientRead(), Server::doneAll(), doneWithControlMsg(), doPeekAndSpliceStep(), endingShutdown(), ESIContext::fail(), fakeAConnectRequest(), getSslContextDone(), getSslContextStart(), handleChunkedRequestBody(), handleRequestBodyData(), ClientRequestContext::hostHeaderIpVerify(), ClientRequestContext::hostHeaderVerify(), ClientRequestContext::hostHeaderVerifyFailed(), httpsEstablish(), httpsSslBumpAccessCheckDone(), httpsSslBumpStep2AccessCheckDone(), isOpen(), kick(), IdentLookup::LookupDone(), HttpRequest::manager(), ACLIdent::match(), ClientHttpRequest::noteAdaptationAclCheckDone(), ClientHttpRequest::noteBodyProducerAborted(), parseHttpRequest(), parseProxy1p0(), parseProxy2p0(), parseTlsHandshake(), pinConnection(), postHttpsAccept(), prepareAcceleratedURL(), prepareTransparentURL(), clientReplyContext::processExpired(), clientReplyContext::processMiss(), clientReplyContext::processOnlyIfCachedMiss(), clientReplyContext::processReplyAccessResult(), proxyProtocolError(), proxyProtocolValidateClient(), clientReplyContext::purgeFoundObject(), clientReplyContext::purgeRequest(), quitAfterError(), readNextRequest(), Server::readSomeData(), receivedFirstByte(), PeerSelector::resolveSelected(), clientReplyContext::sendBodyTooLargeError(), sendControlMsg(), clientReplyContext::sendPreconditionFailedError(), serveDelayedError(), setAuth(), splice(), ClientRequestContext::sslBumpAccessCheckDone(), ClientHttpRequest::sslBumpEstablish(), ClientHttpRequest::sslBumpStart(), sslCrtdHandleReply(), start(), startPeekAndSplice(), statClientRequests(), Server::stopReading(), stopReceiving(), stopSending(), storeTlsContextToCache(), Server::swanSong(), swanSong(), switchToHttps(), tlsAttemptHandshake(), transparent(), tunnelStart(), TunnelStateData::TunnelStateData(), whenClientIpKnown(), Server::write(), and ~ConnStateData().

AsyncCall::Pointer ConnStateData::closeHandler

Definition at line 143 of file client_side.h.

char* ConnStateData::host

Definition at line 135 of file client_side.h.

Referenced by FwdState::connectStart().

const InstanceId<AsyncJob> AsyncJob::id

Definition at line 72 of file AsyncJob.h.

AsyncCall::Pointer AsyncJob::inCall
Ip::Address ConnStateData::log_addr
bool ConnStateData::needProxyProtocolHeader_

Definition at line 384 of file client_side.h.

Referenced by clientParseRequests(), parseProxy1p0(), parseProxy2p0(), and start().

Http1::RequestParserPointer ConnStateData::parser_

Definition at line 392 of file client_side.h.

bool ConnStateData::parsingTlsHandshake

Definition at line 396 of file client_side.h.

Referenced by afterClientRead(), parseTlsHandshake(), and switchToHttps().

CachePeer* ConnStateData::peer

Definition at line 141 of file client_side.h.

Referenced by clientHttpRequestStatus().

bool ConnStateData::pinned

Definition at line 137 of file client_side.h.

Referenced by HttpRequest::pinnedConnection().

SBuf ConnStateData::preservedClientData

client data which may need to forward as-is to server after an on_unsupported_protocol tunnel decision.

Definition at line 311 of file client_side.h.

Referenced by clientTunnelOnError(), parseHttpRequest(), parseTlsHandshake(), and splice().

AsyncCall::Pointer Server::reader
AsyncCall::Pointer ConnStateData::readHandler

Definition at line 142 of file client_side.h.

bool ConnStateData::reading

Definition at line 139 of file client_side.h.

bool ConnStateData::readMore
bool Server::receivedFirstByte_

Definition at line 112 of file Server.h.

Referenced by Server::doClientRead(), receivedFirstByte(), requestTimeout(), and switchToHttps().

Comm::ConnectionPointer ConnStateData::serverConnection

Definition at line 134 of file client_side.h.

Referenced by clientCheckPinning().

Ssl::CertSignAlgorithm ConnStateData::signAlgorithm
SBuf ConnStateData::sslBumpCertKey

Definition at line 404 of file client_side.h.

Referenced by getSslContextStart(), and sslCrtdHandleReply().

SBuf ConnStateData::sslCommonName_

Definition at line 400 of file client_side.h.

Referenced by buildSslCertGenerationParams(), resetSslCommonName(), and sslCommonName().

String ConnStateData::sslConnectHostOrIp

The SSL server host name as passed in the CONNECT request

Definition at line 399 of file client_side.h.

Referenced by buildSslCertGenerationParams(), getSslContextDone(), httpsPeeked(), sslCrtdHandleReply(), and switchToHttps().

const char* ConnStateData::stoppedReceiving_

Definition at line 414 of file client_side.h.

Referenced by stoppedReceiving(), stopReceiving(), and stopSending().

const char* ConnStateData::stoppedSending_

Definition at line 412 of file client_side.h.

Referenced by stoppedSending(), stopReceiving(), and stopSending().

const char* AsyncJob::stopReason
bool ConnStateData::swanSang

Definition at line 131 of file client_side.h.

bool ConnStateData::switchedToHttps_
NotePairs::Pointer ConnStateData::theNotes

Connection annotations, clt_conn_tag and other tags are stored here. If set, are propagated to the current and all future master transactions on the connection.

Definition at line 418 of file client_side.h.

Referenced by hasNotes(), and notes().

SBuf ConnStateData::tlsClientSni_

Definition at line 403 of file client_side.h.

Referenced by fakeAConnectRequest(), parseTlsHandshake(), and tlsClientSni().

Security::HandshakeParser ConnStateData::tlsParser

Tls parser to use for client HELLO messages parsing on bumped connections.

Definition at line 276 of file client_side.h.

Referenced by parseTlsHandshake().

AnyP::ProtocolVersion Server::transferProtocol

The transfer protocol currently being spoken on this connection. HTTP/1.x CONNECT, HTTP/1.1 Upgrade and HTTP/2 SETTINGS offer the ability to change protocols on the fly.

Definition at line 104 of file Server.h.

Referenced by parseHttpRequest(), prepareAcceleratedURL(), prepareTransparentURL(), splice(), and switchToHttps().

AsyncCall::Pointer Server::writer

Definition at line 125 of file Server.h.

Referenced by Server::clientWriteDone(), Server::write(), and Server::writing().

bool ConnStateData::zeroReply

Definition at line 140 of file client_side.h.

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






Web Site Translations