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 "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.


class  ListeningStartedDialer
 dials clientListenerConnectionOpened call More...


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 void prepareAcceleratedURL (ConnStateData *conn, ClientHttpRequest *http, const Http1::RequestParserPointer &hp)
static void prepareTransparentURL (ConnStateData *conn, ClientHttpRequest *http, const Http1::RequestParserPointer &hp)
Http::StreamparseHttpRequest (ConnStateData *csd, const Http1::RequestParserPointer &hp)
bool clientTunnelOnError (ConnStateData *conn, Http::StreamPointer &context, HttpRequest::Pointer &request, const HttpRequestMethod &method, err_type requestError)
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 Comm::ConnectionPointer &conn, 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 (allow_t answer, void *data)
static void httpsAccept (const CommAcceptCbParams &params)
void httpsSslBumpStep2AccessCheckDone (allow_t 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)


static IOACB httpAccept
static CTCB clientLifetimeTimeout
static IDCB clientIdentDone
static const SBuf Proxy1p0magic ("PROXY ", 6)
 magic octet prefix for PROXY protocol version 1 More...
static const SBuf Proxy2p0magic ("\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A", 12)
 magic octet prefix for PROXY protocol version 2 More...

Function Documentation

static bool AddOpenedHttpSocket ( const Comm::ConnectionPointer conn)

Definition at line 3445 of file

References Comm::Connection::fd, HttpSockets, i, and NHttpSockets.

Referenced by clientListenerConnectionOpened().

void clientConnectionsClose ( void  )
static void clientIdentDone ( const char *  ident,
void *  data 
int clientIsRequestBodyTooLargeForPolicy ( int64_t  bodyLength)
static void clientListenerConnectionOpened ( AnyP::PortCfgPointer s,
const Ipc::FdNoteId  portTypeNote,
const Subscription::Pointer sub 
void clientOpenListenSockets ( void  )
void clientPackTermBound ( String  boundary,
MemBuf mb 
bool clientPingHasFinished ( ping_data const *  aPing)

Definition at line 254 of file

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

Referenced by clientUpdateHierCounters().

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

Definition at line 1553 of file

References ClientHttpRequest::Flags::accel, RequestFlags::accelerated, ClientHttpRequest::al, assert, HttpRequest::auth_user_request, AnyP::Uri::authority(), Http::Message::body_pipe, ClientHttpRequest::calloutContext, HttpHeader::chunked(), Server::clientConnection, clientIsContentLengthValid(), clientIsRequestBodyTooLargeForPolicy(), clientProcessRequestFinished(), clientSetKeepaliveFlag(), Config, Http::Message::content_length, clientStreamNode::data, debugs, ClientHttpRequest::doCallouts(), ERR_INVALID_REQ, ERR_TOO_BIG, ERR_UNSUP_REQ, ConnStateData::expectRequestBody(), ConnStateData::flags, ClientHttpRequest::flags, HttpRequest::flags, ConnStateData::getAuth(), Http::Stream::getClientReplyContext(), HttpHeader::getInt64(), HttpHeader::getList(), getMyPort(), RefCount< C >::getRaw(), AnyP::Uri::getScheme(), SquidConfig::global_internal_static, ConnStateData::handleRequestBodyData(), HttpHeader::has(), Http::Message::header, AnyP::Uri::host(), Http::Stream::http, Http::Message::http_ver, RequestFlags::internal, ClientHttpRequest::Flags::internal, internalCheck(), internalHostname(), internalHostnameIs(), internalStaticCheck(), AnyP::ProtocolVersion::major, HttpRequest::manager(), Http::MAX_FORWARDS, Http::Stream::mayUseConnection(), HttpRequest::method, Http::METHOD_CONNECT, Http::METHOD_NONE, Http::METHOD_OPTIONS, AnyP::ProtocolVersion::minor, RequestFlags::noDirect, NULL, ClientHttpRequest::Out::offset, SquidConfig::onoff, ClientHttpRequest::out, AnyP::Uri::path(), AnyP::Uri::port(), ConnStateData::port, BodyPipe::productionEnded(), AnyP::PROTO_HTTP, AnyP::PROTO_HTTPS, AnyP::ProtocolVersion::protocol, Http::Stream::pullData(), ConnStateData::quitAfterError(), ConnStateData::readMore, Comm::Connection::remote, ClientHttpRequest::request, request(), Http::scLengthRequired, Http::scNotImplemented, Http::scPayloadTooLarge, ConnStateData::serveDelayedError(), ClientHttpRequest::setLogUriToRequestUri(), clientReplyContext::setReplyToError(), AnyP::Uri::setScheme(), String::size(), Http::Message::sources, Http::Message::srcFtp, Http::Message::srcHttp, Http::Message::srcHttps, RequestFlags::sslBumped, ConnStateData::switchedToHttps(), Http::TRANSFER_ENCODING, HttpRequest::url, and urlCheckRequest().

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

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 638 of file

References debugs, HttpRequest::flags, Http::Message::http_ver, HttpRequest::method, Http::Message::persistent(), RequestFlags::proxyKeepalive, ClientHttpRequest::request, and request().

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

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

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 867 of file

References assert, Server::clientConnection, clientSocketRecipient, debugs, and HERE().

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

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 828 of file

References assert, cbdataReferenceValid(), clientStreamDetach(), clientStreamNode::data, RefCount< C >::getRaw(), dlink_node::next, clientStreamNode::node, and NULL.

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 789 of file

References assert, HttpControlMsgSink::cbControlMsgSent, cbdataReferenceValid(), Server::clientConnection, clientSocketRecipient, clientStreamNode::data, Pipeline::front(), ClientHttpRequest::getConn(), RefCount< C >::getRaw(), ConnStateData::handleReply(), Comm::IsConnOpen(), dlink_node::next, clientStreamNode::node, NULL, Server::pipeline, PROF_start, and PROF_stop.

void clientUpdateStatHistCounters ( const LogTags logType,
int  svc_time 

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 212 of file

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

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 1063 of file

References assert, NULL, and xisspace.

Referenced by HttpRequest::parseFirstLine().

void httpRequestFree ( void *  data)

Definition at line 485 of file

References assert, and NULL.

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

static void httpsEstablish ( ConnStateData connState,
const Security::ContextPointer ctx 
static void httpsSslBumpAccessCheckDone ( allow_t  answer,
void *  data 
static bool OpenedHttpSocket ( const Comm::ConnectionPointer c,
const Ipc::FdNoteId  portType 
std::ostream& operator<< ( std::ostream &  os,
const ConnStateData::PinnedIdleContext pic 
Http::Stream* parseHttpRequest ( ConnStateData csd,
const Http1::RequestParserPointer hp 

Parse an HTTP request

Sets result->flags.parsed_ok to 0 if failed to parse the request, to 1 if the request was correctly parsed.
[in]csda ConnStateData. The caller must make sure it is not null
[in]hpan Http1::RequestParser
[out]mehtod_pwill be set as a side-effect of the parsing. Pointed-to value will be set to Http::METHOD_NONE in case of parsing failure
[out]http_verwill be set as a side-effect of the parsing
NULL on incomplete requests, a Http::Stream on success or failure.

Definition at line 1242 of file

References ConnStateData::abortRequestParsing(), SBuf::append(), SquidConfig::appendDomainLen, Server::clientConnection, clientGetMoreData, clientReplyDetach, clientReplyStatus, clientSocketDetach, clientSocketRecipient, clientStreamInit(), Config, ConnStateData::consumeInput(), StoreIOBuffer::data, DBG_IMPORTANT, debugs, Http::Stream::flags, HTTP_REQBUF_SZ, Server::inBuf, internalCheck(), internalLocalUri(), SBuf::isEmpty(), StoreIOBuffer::length, SBuf::length(), ConnStateData::mayTunnelUnsupportedProto(), Http::METHOD_CONNECT, Http::METHOD_NONE, Http::METHOD_PRI, NULL, Http::Stream::parsed_ok, ConnStateData::port, prepareAcceleratedURL(), prepareTransparentURL(), ConnStateData::preservedClientData, Http::ProtocolVersion(), Http::Stream::reqbuf, SBufToCstring(), Http::scMethodNotAllowed, Http::scRequestHeaderFieldsTooLarge, Http::scUriTooLong, ConnStateData::switchedToHttps(), Server::transferProtocol, ConnStateData::transparent(), xcalloc, and xstrdup.

Referenced by Http::One::Server::parseOneRequest().

char * skipLeadingSpace ( char *  aString)

Definition at line 1047 of file

References xisspace.

static int tlsAttemptHandshake ( ConnStateData conn,
PF callback 

Variable Documentation

IDCB clientIdentDone

Definition at line 174 of file

Referenced by ConnStateData::whenClientIpKnown().

CTCB clientLifetimeTimeout
IOACB httpAccept

Definition at line 171 of file

Referenced by clientHttpConnectionsOpen().

const SBuf Proxy1p0magic("PROXY ", 6)
const SBuf Proxy2p0magic("\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A", 12)






Web Site Translations