client_side.cc File Reference
#include "squid.h"
#include "acl/FilledChecklist.h"
#include "anyp/PortCfg.h"
#include "base/Subscription.h"
#include "base/TextException.h"
#include "CachePeer.h"
#include "client_db.h"
#include "client_side.h"
#include "client_side_reply.h"
#include "client_side_request.h"
#include "ClientRequestContext.h"
#include "clientStream.h"
#include "comm.h"
#include "comm/Connection.h"
#include "comm/Loops.h"
#include "comm/Read.h"
#include "comm/TcpAcceptor.h"
#include "comm/Write.h"
#include "CommCalls.h"
#include "errorpage.h"
#include "fd.h"
#include "fde.h"
#include "fqdncache.h"
#include "FwdState.h"
#include "globals.h"
#include "helper.h"
#include "helper/Reply.h"
#include "http.h"
#include "http/one/RequestParser.h"
#include "http/one/TeChunkedParser.h"
#include "http/Stream.h"
#include "HttpHdrContRange.h"
#include "HttpHeaderTools.h"
#include "HttpReply.h"
#include "HttpRequest.h"
#include "ident/Config.h"
#include "ident/Ident.h"
#include "internal.h"
#include "ipc/FdNotes.h"
#include "ipc/StartListening.h"
#include "log/access_log.h"
#include "MemBuf.h"
#include "MemObject.h"
#include "mime_header.h"
#include "parser/Tokenizer.h"
#include "profiler/Profiler.h"
#include "proxyp/Header.h"
#include "proxyp/Parser.h"
#include "security/NegotiationHistory.h"
#include "servers/forward.h"
#include "SquidConfig.h"
#include "SquidTime.h"
#include "StatCounters.h"
#include "StatHist.h"
#include "Store.h"
#include "TimeOrTag.h"
#include "tools.h"
#include "auth/UserRequest.h"
#include "ClientInfo.h"
#include "MessageDelayPools.h"
#include "ssl/bio.h"
#include "ssl/context_storage.h"
#include "ssl/gadgets.h"
#include "ssl/helper.h"
#include "ssl/ProxyCerts.h"
#include "ssl/ServerBump.h"
#include "ssl/support.h"
#include "util.h"
#include <climits>
#include <cmath>
#include <limits>

Go to the source code of this file.

Classes

class  ListeningStartedDialer
 dials clientListenerConnectionOpened call More...
 

Functions

static void clientListenerConnectionOpened (AnyP::PortCfgPointer &s, const Ipc::FdNoteId portTypeNote, const Subscription::Pointer &sub)
 process clientHttpConnectionsOpen result More...
 
static int clientIsContentLengthValid (HttpRequest *r)
 checks body length of non-chunked requests More...
 
static int clientIsRequestBodyTooLargeForPolicy (int64_t bodyLength)
 
static void clientUpdateStatHistCounters (const LogTags &logType, int svc_time)
 
static void clientUpdateStatCounters (const LogTags &logType)
 
static void clientUpdateHierCounters (HierarchyLogEntry *)
 
static bool clientPingHasFinished (ping_data const *aPing)
 
void prepareLogWithRequestDetails (HttpRequest *, AccessLogEntry::Pointer &)
 
static void ClientSocketContextPushDeferredIfNeeded (Http::StreamPointer deferredRequest, ConnStateData *conn)
 
char * skipLeadingSpace (char *aString)
 
static void clientIdentDone (const char *ident, void *data)
 
void httpRequestFree (void *data)
 
void clientSetKeepaliveFlag (ClientHttpRequest *http)
 decide whether to expect multiple requests on the corresponding connection More...
 
void clientPackTermBound (String boundary, MemBuf *mb)
 put terminating boundary for multiparts to the buffer More...
 
void clientPackRangeHdr (const HttpReplyPointer &rep, const HttpHdrRangeSpec *spec, String boundary, MemBuf *mb)
 append a "part" HTTP header (as in a multi-part/range reply) to the buffer More...
 
void clientSocketRecipient (clientStreamNode *node, ClientHttpRequest *http, HttpReply *rep, StoreIOBuffer receivedData)
 
void clientSocketDetach (clientStreamNode *node, ClientHttpRequest *http)
 
const char * findTrailingHTTPVersion (const char *uriAndHTTPVersion, const char *end)
 
static char * prepareAcceleratedURL (ConnStateData *conn, const Http1::RequestParserPointer &hp)
 
static char * buildUrlFromHost (ConnStateData *conn, const Http1::RequestParserPointer &hp)
 
static char * prepareTransparentURL (ConnStateData *conn, const Http1::RequestParserPointer &hp)
 
bool clientTunnelOnError (ConnStateData *conn, Http::StreamPointer &context, HttpRequest::Pointer &request, const HttpRequestMethod &method, err_type requestError)
 ConnStateData::tunnelOnError() wrapper. Reduces code changes. TODO: Remove. More...
 
void clientProcessRequestFinished (ConnStateData *conn, const HttpRequest::Pointer &request)
 
void clientProcessRequest (ConnStateData *conn, const Http1::RequestParserPointer &hp, Http::Stream *context)
 
static void clientLifetimeTimeout (const CommTimeoutCbParams &io)
 
void httpAccept (const CommAcceptCbParams &params)
 
static bool httpsCreate (const ConnStateData *connState, const Security::ContextPointer &ctx)
 Create TLS connection structure and update fd_table. More...
 
static int tlsAttemptHandshake (ConnStateData *conn, PF *callback)
 
static void clientNegotiateSSL (int fd, void *data)
 
static void httpsEstablish (ConnStateData *connState, const Security::ContextPointer &ctx)
 
static void httpsSslBumpAccessCheckDone (Acl::Answer answer, void *data)
 
static void httpsAccept (const CommAcceptCbParams &params)
 
void httpsSslBumpStep2AccessCheckDone (Acl::Answer answer, void *data)
 
static bool OpenedHttpSocket (const Comm::ConnectionPointer &c, const Ipc::FdNoteId portType)
 check FD after clientHttp[s]ConnectionOpened, adjust HttpSockets as needed More...
 
static bool AddOpenedHttpSocket (const Comm::ConnectionPointer &conn)
 find any unused HttpSockets[] slot and store fd there or return false More...
 
static void clientHttpConnectionsOpen (void)
 
void clientStartListeningOn (AnyP::PortCfgPointer &port, const RefCount< CommCbFunPtrCallT< CommAcceptCbPtrFun > > &subCall, const Ipc::FdNoteId fdNote)
 accept requests to a given port and inform subCall about them More...
 
void clientOpenListenSockets (void)
 
void clientConnectionsClose ()
 
int varyEvaluateMatch (StoreEntry *entry, HttpRequest *request)
 
ACLFilledChecklistclientAclChecklistCreate (const acl_access *acl, ClientHttpRequest *http)
 
void clientAclChecklistFill (ACLFilledChecklist &checklist, ClientHttpRequest *http)
 
std::ostream & operator<< (std::ostream &os, const ConnStateData::PinnedIdleContext &pic)
 

Variables

static IOACB httpAccept
 
static CTCB clientLifetimeTimeout
 
static IDCB clientIdentDone
 

Function Documentation

◆ AddOpenedHttpSocket()

static bool AddOpenedHttpSocket ( const Comm::ConnectionPointer conn)
static

Definition at line 3357 of file client_side.cc.

References conn, HttpSockets, i, and NHttpSockets.

Referenced by clientListenerConnectionOpened().

◆ buildUrlFromHost()

static char* buildUrlFromHost ( ConnStateData conn,
const Http1::RequestParserPointer hp 
)
static

◆ clientAclChecklistCreate()

◆ clientAclChecklistFill()

◆ clientConnectionsClose()

void clientConnectionsClose ( void  )

◆ clientHttpConnectionsOpen()

◆ clientIdentDone()

static void clientIdentDone ( const char *  ident,
void *  data 
)
static

Definition at line 196 of file client_side.cc.

References conn, dash_str, data, USER_IDENT_SZ, and xstrncpy().

◆ clientIsContentLengthValid()

◆ clientIsRequestBodyTooLargeForPolicy()

int clientIsRequestBodyTooLargeForPolicy ( int64_t  bodyLength)
static

◆ clientLifetimeTimeout()

◆ clientListenerConnectionOpened()

static void clientListenerConnectionOpened ( AnyP::PortCfgPointer s,
const Ipc::FdNoteId  portTypeNote,
const Subscription::Pointer sub 
)
static

◆ clientNegotiateSSL()

static void clientNegotiateSSL ( int  fd,
void *  data 
)
static

◆ clientOpenListenSockets()

void clientOpenListenSockets ( void  )

◆ clientPackRangeHdr()

◆ clientPackTermBound()

void clientPackTermBound ( String  boundary,
MemBuf mb 
)

◆ clientPingHasFinished()

bool clientPingHasFinished ( ping_data const *  aPing)
static

Definition at line 260 of file client_side.cc.

References ping_data::start, and ping_data::stop.

Referenced by clientUpdateHierCounters().

◆ clientProcessRequest()

void clientProcessRequest ( ConnStateData conn,
const Http1::RequestParserPointer hp,
Http::Stream context 
)

Definition at line 1607 of file client_side.cc.

References ClientHttpRequest::Flags::accel, ClientHttpRequest::al, assert, ClientHttpRequest::calloutContext, clientIsContentLengthValid(), clientIsRequestBodyTooLargeForPolicy(), clientProcessRequestFinished(), clientSetKeepaliveFlag(), Config, conn, _request::content_length, debugs, ClientHttpRequest::doCallouts(), ERR_INVALID_REQ, ERR_TOO_BIG, ERR_UNSUP_REQ, ClientHttpRequest::flags, Http::Stream::getClientReplyContext(), getMyPort(), SquidConfig::global_internal_static, Http::Stream::http, ClientHttpRequest::Flags::internal, internalCheck(), internalHostname(), internalHostnameIs(), internalStaticCheck(), AnyP::ProtocolVersion::major, Http::MAX_FORWARDS, Http::Stream::mayUseConnection(), HttpRequest::method, _request::method, Http::METHOD_CONNECT, Http::METHOD_NONE, Http::METHOD_OPTIONS, AnyP::ProtocolVersion::minor, NULL, ClientHttpRequest::Out::offset, SquidConfig::onoff, ClientHttpRequest::out, AnyP::PROTO_HTTP, AnyP::PROTO_HTTPS, AnyP::ProtocolVersion::protocol, Http::Stream::pullData(), ClientHttpRequest::request, request(), Http::scLengthRequired, Http::scNotImplemented, Http::scPayloadTooLarge, ClientHttpRequest::setLogUriToRequestUri(), clientReplyContext::setReplyToError(), String::size(), Http::Message::srcFtp, Http::Message::srcHttp, Http::Message::srcHttps, Http::TRANSFER_ENCODING, _request::url, and urlCheckRequest().

Referenced by Ftp::Server::doProcessRequest(), Http::One::Server::proceedAfterBodyContinuation(), and Http::One::Server::processParsedRequest().

◆ clientProcessRequestFinished()

◆ clientSetKeepaliveFlag()

void clientSetKeepaliveFlag ( ClientHttpRequest http)

clientSetKeepaliveFlag() sets request->flags.proxyKeepalive. This is the client-side persistent connection flag. We need to set this relatively early in the request processing to handle hacks for broken servers and clients.

Definition at line 648 of file client_side.cc.

References debugs, _request::method, ClientHttpRequest::request, and request().

Referenced by clientProcessRequest(), and Ftp::Server::doProcessRequest().

◆ ClientSocketContextPushDeferredIfNeeded()

static void ClientSocketContextPushDeferredIfNeeded ( Http::StreamPointer  deferredRequest,
ConnStateData conn 
)
static

If the client stream is waiting on a socket write to occur, then

NO data is allowed to have been sent.

defer now.

otherwise, the request is still active in a callbacksomewhere, and we are done

Definition at line 877 of file client_side.cc.

References assert, clientSocketRecipient(), conn, debugs, and HERE().

Referenced by ConnStateData::doneWithControlMsg(), and ConnStateData::kick().

◆ clientSocketDetach()

void clientSocketDetach ( clientStreamNode node,
ClientHttpRequest http 
)

Called when a downstream node is no longer interested in our data. As we are a terminal node, this means on aborts only

Definition at line 838 of file client_side.cc.

References assert, cbdataReferenceValid(), clientStreamDetach(), node::next, and NULL.

Referenced by ConnStateData::abortRequestParsing(), ConnStateData::buildFakeRequest(), and ConnStateData::parseHttpRequest().

◆ clientSocketRecipient()

void clientSocketRecipient ( clientStreamNode node,
ClientHttpRequest http,
HttpReply rep,
StoreIOBuffer  receivedData 
)

Write a chunk of data to a client socket. If the reply is present, send the reply headers down the wire too, and clean them up when finished. Pre-condition: The request is one backed by a connection, not an internal request. data context is not NULL There are no more entries in the stream chain.

Definition at line 799 of file client_side.cc.

References assert, HttpControlMsgSink::cbControlMsgSent, cbdataReferenceValid(), Server::clientConnection, Pipeline::front(), ClientHttpRequest::getConn(), ConnStateData::handleReply(), Comm::IsConnOpen(), node::next, NULL, Server::pipeline, PROF_start, and PROF_stop.

Referenced by ConnStateData::abortRequestParsing(), ConnStateData::buildFakeRequest(), ClientSocketContextPushDeferredIfNeeded(), and ConnStateData::parseHttpRequest().

◆ clientStartListeningOn()

◆ clientTunnelOnError()

bool clientTunnelOnError ( ConnStateData conn,
Http::StreamPointer context,
HttpRequest::Pointer request,
const HttpRequestMethod method,
err_type  requestError 
)

◆ clientUpdateHierCounters()

◆ clientUpdateStatCounters()

◆ clientUpdateStatHistCounters()

void clientUpdateStatHistCounters ( const LogTags logType,
int  svc_time 
)
static

The idea here is not to be complete, but to get service times for only well-defined types. For example, we don't include LOG_TCP_REFRESH_FAIL because its not really a cache hit (we tried to validate it, but failed).

Definition at line 218 of file client_side.cc.

References StatCounters::allSvcTime, StatCounters::client_http, StatHist::count(), StatCounters::hitSvcTime, LOG_TCP_CLIENT_REFRESH_MISS, LOG_TCP_HIT, LOG_TCP_IMS_HIT, LOG_TCP_INM_HIT, LOG_TCP_MEM_HIT, LOG_TCP_MISS, LOG_TCP_OFFLINE_HIT, LOG_TCP_REFRESH_UNMODIFIED, StatCounters::missSvcTime, StatCounters::nearHitSvcTime, StatCounters::nearMissSvcTime, LogTags::oldType, and statCounter.

Referenced by ClientHttpRequest::updateCounters().

◆ findTrailingHTTPVersion()

const char* findTrailingHTTPVersion ( const char *  uriAndHTTPVersion,
const char *  end 
)

'end' defaults to NULL for backwards compatibility remove default value if we ever get rid of NULL-terminated request buffers.

Definition at line 1073 of file client_side.cc.

References assert, NULL, and xisspace.

Referenced by HttpRequest::parseFirstLine().

◆ httpAccept()

◆ httpRequestFree()

void httpRequestFree ( void *  data)

Definition at line 495 of file client_side.cc.

References assert, data, and NULL.

Referenced by esiBufferRecipient(), ClientHttpRequest::~ClientHttpRequest(), and Http::Stream::~Stream().

◆ httpsAccept()

◆ httpsCreate()

◆ httpsEstablish()

static void httpsEstablish ( ConnStateData connState,
const Security::ContextPointer ctx 
)
static

◆ httpsSslBumpAccessCheckDone()

◆ httpsSslBumpStep2AccessCheckDone()

◆ OpenedHttpSocket()

static bool OpenedHttpSocket ( const Comm::ConnectionPointer c,
const Ipc::FdNoteId  portType 
)
static

◆ operator<<()

std::ostream& operator<< ( std::ostream &  os,
const ConnStateData::PinnedIdleContext pic 
)

◆ prepareAcceleratedURL()

◆ prepareLogWithRequestDetails()

◆ prepareTransparentURL()

static char* prepareTransparentURL ( ConnStateData conn,
const Http1::RequestParserPointer hp 
)
static

◆ skipLeadingSpace()

char * skipLeadingSpace ( char *  aString)

Definition at line 1057 of file client_side.cc.

References xisspace.

◆ tlsAttemptHandshake()

static int tlsAttemptHandshake ( ConnStateData conn,
PF callback 
)
static
Return values
1on success
0when needs more data
-1on error

Definition at line 2378 of file client_side.cc.

References callback, COMM_SELECT_READ, COMM_SELECT_WRITE, conn, DBG_IMPORTANT, debugs, Security::ErrorString(), fatal(), fd_table, Comm::SetSelect(), and xstrerr().

Referenced by clientNegotiateSSL(), and ConnStateData::startPeekAndSplice().

◆ varyEvaluateMatch()

Variable Documentation

◆ clientIdentDone

IDCB clientIdentDone
static

Definition at line 180 of file client_side.cc.

Referenced by ConnStateData::whenClientIpKnown().

◆ clientLifetimeTimeout

CTCB clientLifetimeTimeout
static

◆ httpAccept

IOACB httpAccept
static

Definition at line 177 of file client_side.cc.

Referenced by clientHttpConnectionsOpen().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors