client_side.cc File Reference
#include "squid.h"
#include "acl/FilledChecklist.h"
#include "anyp/PortCfg.h"
#include "base/AsyncCallbacks.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 "debug/Messages.h"
#include "error/ExceptionErrorDetail.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 "proxyp/Header.h"
#include "proxyp/Parser.h"
#include "sbuf/Stream.h"
#include "security/Certificate.h"
#include "security/CommunicationSecrets.h"
#include "security/Io.h"
#include "security/KeyLog.h"
#include "security/NegotiationHistory.h"
#include "servers/forward.h"
#include "SquidConfig.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 <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 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 *, const AccessLogEntryPointer &)
 
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)
 
void clientProcessRequestFinished (ConnStateData *conn, const HttpRequest::Pointer &request)
 
void clientProcessRequest (ConnStateData *conn, const Http1::RequestParserPointer &hp, Http::Stream *context)
 
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 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)
 
static 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)
 
std::ostream & operator<< (std::ostream &os, const ConnStateData::ServerConnectionContext &scc)
 

Variables

static IOACB httpAccept
 
static IDCB clientIdentDone
 

Function Documentation

◆ AddOpenedHttpSocket()

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

Definition at line 3262 of file client_side.cc.

References conn, HttpSockets, 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 203 of file client_side.cc.

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

◆ clientIsRequestBodyTooLargeForPolicy()

int clientIsRequestBodyTooLargeForPolicy ( int64_t  bodyLength)
static

◆ clientListenerConnectionOpened()

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

◆ clientNegotiateSSL()

◆ clientOpenListenSockets()

void clientOpenListenSockets ( void  )

◆ clientPackRangeHdr()

◆ clientPackTermBound()

void clientPackTermBound ( String  boundary,
MemBuf mb 
)

◆ clientPingHasFinished()

bool clientPingHasFinished ( ping_data const *  aPing)
static

Definition at line 267 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 1588 of file client_side.cc.

References ClientHttpRequest::Flags::accel, RequestFlags::accelerated, ClientHttpRequest::al, assert, HttpRequest::auth_user_request, Http::Message::body_pipe, ClientHttpRequest::calloutContext, HttpRequest::checkEntityFraming(), ClientHttpRequest::checkForInternalAccess(), HttpHeader::chunked(), clientIsRequestBodyTooLargeForPolicy(), clientProcessRequestFinished(), clientSetKeepaliveFlag(), conn, Http::Message::content_length, debugs, ClientHttpRequest::doCallouts(), ERR_INVALID_REQ, ERR_TOO_BIG, ERR_UNSUP_REQ, ClientHttpRequest::flags, HttpRequest::flags, Http::Stream::getClientReplyContext(), HttpHeader::getInt64(), RefCount< C >::getRaw(), Http::Message::header, Http::Stream::http, Http::Message::http_ver, AnyP::ProtocolVersion::major, HttpRequest::manager(), Http::MAX_FORWARDS, Http::Stream::mayUseConnection(), HttpRequest::method, Http::METHOD_CONNECT, Http::METHOD_OPTIONS, AnyP::ProtocolVersion::minor, RequestFlags::noDirect, ClientHttpRequest::Out::offset, ClientHttpRequest::out, BodyPipe::productionEnded(), AnyP::PROTO_HTTPS, AnyP::ProtocolVersion::protocol, Http::Stream::pullData(), ClientHttpRequest::request, Http::scContentTooLarge, Http::scNone, Http::scNotImplemented, clientReplyContext::setReplyToError(), Http::Message::sources, Http::Message::srcFtp, Http::Message::srcHttp, Http::Message::srcHttps, RequestFlags::sslBumped, 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 698 of file client_side.cc.

References debugs, HttpRequest::flags, Http::Message::http_ver, HttpRequest::method, Http::Message::persistent(), RequestFlags::proxyKeepalive, and ClientHttpRequest::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 896 of file client_side.cc.

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

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 860 of file client_side.cc.

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

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 824 of file client_side.cc.

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

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

◆ clientStartListeningOn()

◆ 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 225 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 1076 of file client_side.cc.

References assert, and xisspace.

Referenced by HttpRequest::parseFirstLine().

◆ httpAccept()

◆ httpRequestFree()

void httpRequestFree ( void *  data)

Definition at line 499 of file client_side.cc.

References assert.

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

◆ 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<<() [1/2]

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

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  os,
const ConnStateData::ServerConnectionContext scc 
)

Definition at line 4055 of file client_side.cc.

◆ prepareAcceleratedURL()

◆ prepareLogWithRequestDetails()

◆ prepareTransparentURL()

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

◆ skipLeadingSpace()

char * skipLeadingSpace ( char *  aString)

Definition at line 1060 of file client_side.cc.

References xisspace.

◆ varyEvaluateMatch()

Variable Documentation

◆ clientIdentDone

IDCB clientIdentDone
static

Definition at line 188 of file client_side.cc.

Referenced by ConnStateData::whenClientIpKnown().

◆ httpAccept

IOACB httpAccept
static

Definition at line 186 of file client_side.cc.

Referenced by clientHttpConnectionsOpen().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors