client_side_request.cc
Go to the documentation of this file.
87 ErrorState *clientBuildError(err_type, Http::StatusCode, char const *url, const ConnStateData *, HttpRequest *, const AccessLogEntry::Pointer &);
357 Debug::Extra << "addresses allowed by follow_x_forwarded_for: " << calloutContext->currentXffHopNumber <<
378 debugs(28, DBG_CRITICAL, "ERROR: Processing X-Forwarded-For. Stopping at IP address: " << request->indirect_client_addr );
394 ClientRequestContext::hostHeaderIpVerify(const ipcache_addrs* ia, const Dns::LookupDetails &dns)
418 debugs(85, 3, "SECURITY ALERT: Host header forgery detected on " << http->getConn()->clientConnection <<
429 // XXX: when we have sorted out the best way to relay requests properly to peers this hierarchical limit can go.
512 debugs(85, 3, "validate host=" << host << ", port=" << port << ", portStr=" << (portStr?portStr:"NULL"));
530 debugs(85, 3, "FAIL on validate URL domain length " << http->request->url.host() << " matches Host: " << host);
534 debugs(85, 3, "FAIL on validate URL domain " << http->request->url.host() << " matches Host: " << host);
541 debugs(85, 3, "FAIL on validate URL port " << *http->request->url.port() << " matches Host: port " << portStr);
543 } else if (!portStr && http->request->method != Http::METHOD_CONNECT && http->request->url.port() != http->request->url.getScheme().defaultPort()) {
546 debugs(85, 3, "FAIL on validate URL port " << http->request->url.port().value_or(0) << " matches Host: default port " << http->request->url.getScheme().defaultPort().value_or(0));
571 http->request->x_forwarded_for_iterator = http->request->header.getList(Http::HdrType::X_FORWARDED_FOR);
575 ACLFilledChecklist::NonBlockingCheck(std::move(acl_checklist), clientFollowXForwardedForCheck, this);
582 ACLFilledChecklist::NonBlockingCheck(std::move(acl_checklist), clientAccessCheckDoneWrapper, this);
599 ACLFilledChecklist::NonBlockingCheck(std::move(acl_checklist), clientAccessCheckDoneWrapper, this);
638 const auto auth_challenge = (answer == ACCESS_AUTH_REQUIRED || aclIsProxyAuth(answer.lastCheckedName));
744 ACLFilledChecklist::NonBlockingCheck(std::move(acl_checklist), clientRedirectAccessCheckDone, this);
780 ACLFilledChecklist::NonBlockingCheck(std::move(acl_checklist), clientStoreIdAccessCheckDone, this);
792 if (!request->flags.hostVerified && (request->flags.intercepted || request->flags.interceptTproxy))
856 if (req_hdr->has(Http::HdrType::AUTHORIZATION) || req_hdr->has(Http::HdrType::PROXY_AUTHORIZATION)) {
904 // RFC 2616: treat Pragma:no-cache as if it was Cache-Control:no-cache when Cache-Control is missing
1073 debugs(85, DBG_IMPORTANT, "ERROR: URL rewrite helper returned invalid result code. Wrong helper? " << reply);
1115 debugs(85, DBG_CRITICAL, "ERROR: URL-rewrite produces invalid " << status << " redirect Location: " << urlNote);
1127 debugs(61, 2, "URL-rewriter diverts URL from " << old_request->effectiveRequestUri() << " to " << new_request->effectiveRequestUri());
1181 debugs(85, DBG_IMPORTANT, "ERROR: storeID helper returned invalid result code. Wrong helper? " << reply);
1312 ACLFilledChecklist::NonBlockingCheck(std::move(aclChecklist), sslBumpAccessCheckDoneWrapper, this);
1342 const Comm::ConnectionPointer clientConn = http->getConn() ? http->getConn()->clientConnection : nullptr;
1408 SslBumpEstablish(const Comm::ConnectionPointer &, char *, size_t, Comm::Flag errflag, int, void *data)
1556 debugs(33, 3, "internal URL found: " << request->url.getScheme() << "://" << request->url.authority(true));
1559 debugs(33, 3, "internal URL found: " << request->url.getScheme() << "://" << request->url.authority(true) << " (global_internal_static on)");
1566 debugs(33, 3, "internal URL found: " << request->url.getScheme() << "://" << request->url.authority(true) << " (not this proxy)");
1826 const auto canonicalUri = urlCanonicalCleanWithoutRequest(errorUri, HttpRequestMethod(), AnyP::UriScheme());
2024 storeEntry()->completeSuccessfully("received, consumed, and, hence, stored the entire REQMOD reply");
2050 ClientHttpRequest::handleAdaptationFailure(const ErrorDetail::Pointer &errDetail, bool bypassable)
2087 debugs(85, DBG_IMPORTANT, "ClientHttpRequest exception without connection. Ignoring " << ex.what());
Definition: parse.c:104
Definition: AsyncJob.h:31
void setLogUriToRawUri(const char *, const HttpRequestMethod &)
Definition: client_side_request.cc:1794
void resetRequest(HttpRequest *)
Definition: client_side_request.cc:1528
ClientHttpRequest(ConnStateData *)
Definition: client_side_request.cc:128
Definition: FilledChecklist.h:33
static HLPCB clientRedirectDoneWrapper
Definition: client_side_request.cc:99
Definition: ipcache.h:50
bool initiated(const CbcPointer< AsyncJob > &job) const
Must(initiated(initiate)) instead of Must(initiate.set()), for clarity.
Definition: Initiator.h:52
void ignoreRange(const char *reason)
forgets about the cached Range header (for a reason)
Definition: HttpRequest.cc:621
void clientAccessCheck()
Definition: client_side_request.cc:559
void setServerBump(Ssl::ServerBump *srvBump)
Definition: client_side.h:286
void noteAdaptationAnswer(const Adaptation::Answer &) override
Definition: client_side_request.cc:1873
void resetRequestXXX(HttpRequest *, bool uriChanged)
Definition: client_side_request.cc:1535
struct SquidConfig::@85 Port
Definition: Acl.h:53
struct SquidConfig::@98 accessList
int setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark)
Definition: QosConfig.cc:589
void setAuth(const Auth::UserRequest::Pointer &aur, const char *cause)
Definition: client_side.cc:494
struct ClientHttpRequest::Redirect redirect
int hasListMember(Http::HdrType id, const char *member, const char separator) const
Definition: HttpHeader.cc:1662
void errorAppendEntry(StoreEntry *entry, ErrorState *err)
Definition: errorpage.cc:738
#define FAILURE_MODE_TIME
void initRequest(HttpRequest *)
Definition: client_side_request.cc:1511
const ProxyProtocol::HeaderPointer & proxyProtocolHeader() const
Definition: client_side.h:360
void clientStreamRead(clientStreamNode *thisObject, ClientHttpRequest *http, StoreIOBuffer readBuffer)
Definition: clientStream.cc:170
static void clientAccessCheckDoneWrapper(Acl::Answer, void *)
Definition: client_side_request.cc:607
bool readNextRequest
whether Squid should read after error handling
Definition: ClientRequestContext.h:83
const SBuf & lastCheckDescription() const
describes the ACL that was evaluated last while obtaining this answer (for debugging)
Definition: Acl.cc:123
void error(char *format,...)
void hostHeaderIpVerify(const ipcache_addrs *, const Dns::LookupDetails &)
Definition: client_side_request.cc:394
bool sslBumpNeeded() const
returns true if and only if the request needs to be bumped
Definition: client_side_request.h:197
void clientAccessCheck2()
Definition: client_side_request.cc:595
struct SquidConfig::@90 Program
int64_t prepPartialResponseGeneration()
Definition: client_side_request.cc:1834
Comm::ConnectionPointer serverConnection
Definition: client_side.h:143
ErrorState * error
saved error page for centralized/delayed processing
Definition: ClientRequestContext.h:84
void startAdaptation(const Adaptation::ServiceGroupPointer &)
Initiate an asynchronous adaptation transaction which will call us back.
Definition: client_side_request.cc:1859
void handleAdaptationFailure(const ErrorDetail::Pointer &, bool bypassable=false)
Definition: client_side_request.cc:2050
bool done_follow_x_forwarded_for
Definition: RequestFlags.h:108
void updateLoggingTags(const LogTags_ot code)
update the code in the transaction processing tags
Definition: client_side_request.h:91
double request_failure_ratio
struct ClientHttpRequest::Flags flags
bool have(const Ip::Address &ip, size_t *position=nullptr) const
Definition: ipcache.cc:984
void clientAccessCheckDone(const Acl::Answer &)
Definition: client_side_request.cc:618
static int clientHierarchical(ClientHttpRequest *http)
Definition: client_side_request.cc:786
clientStream_status_t CSS(clientStreamNode *, ClientHttpRequest *)
Definition: clientStreamForward.h:35
struct SquidConfig::@97 onoff
bool adapted_http_access_done
Definition: ClientRequestContext.h:70
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
struct ClientHttpRequest::Out out
void detailError(const ErrorDetail::Pointer &dCode)
set error type-specific detail code
Definition: errorpage.h:111
struct ConnStateData::@35 flags
static void clientFollowXForwardedForCheck(Acl::Answer answer, void *data)
Definition: client_side_request.cc:302
ACLFilledChecklist::MakingPointer clientAclChecklistCreate(const acl_access *acl, ClientHttpRequest *http)
Definition: client_side.cc:3457
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
Definition: FilledChecklist.h:124
bool request_satisfaction_mode
Definition: client_side_request.h:249
#define SQUID_X_FORWARDED_FOR_HOP_MAX
Definition: client_side_request.cc:81
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
Definition: store.cc:1705
ClientRequestContext(ClientHttpRequest *)
Definition: client_side_request.cc:120
void assignRequest(HttpRequest *)
Definition: client_side_request.cc:1574
int matchDomainName(const char *h, const char *d, MatchDomainNameFlags flags)
Definition: Uri.cc:860
bool respMaybeCacheable() const
Definition: RequestMethod.cc:208
void detailError(const err_type c, const ErrorDetail::Pointer &d)
sets error detail if no earlier detail was available
Definition: HttpRequest.h:101
time_t hit_only_mode_until
CbcPointer< Initiate > initiateAdaptation(Initiate *x)
< starts freshly created initiate and returns a safe pointer to it
Definition: Initiator.cc:23
Definition: AccessLogEntry.h:40
bool setConsumerIfNotLate(const Consumer::Pointer &aConsumer)
Definition: BodyPipe.cc:228
Definition: UriScheme.h:31
void clientRedirectStart()
Definition: client_side_request.cc:738
void noteBodyProductionEnded(BodyPipe::Pointer) override
Definition: client_side_request.cc:1999
RefCount< AsyncCallT< Dialer > > asyncCall(int aDebugSection, int aDebugLevel, const char *aName, const Dialer &aDialer)
Definition: AsyncCall.h:156
void checkForInternalAccess()
Checks whether the current request is internal and adjusts it accordingly.
Definition: client_side_request.cc:1550
void syncAle(HttpRequest *adaptedRequest, const char *logUri) const override
assigns uninitialized adapted_request and url ALE components
Definition: FilledChecklist.cc:110
static void hostHeaderIpVerifyWrapper(const ipcache_addrs *ia, const Dns::LookupDetails &dns, void *data)
Definition: client_side_request.cc:387
void fvdbCountVia(const SBuf &)
err_type FindDenyInfoPage(const Acl::Answer &answer, const bool redirect_allowed)
Definition: Gadgets.cc:34
Definition: clientStream.h:75
static void Reset()
forgets the current context, setting it to nil/unknown
Definition: CodeContext.cc:77
Definition: HttpHeader.h:50
Definition: Range.h:18
void endRequestSatisfaction()
Definition: client_side_request.cc:2013
void checkNoCache()
applies "cache allow/deny" rules, asynchronously if needed
Definition: client_side_request.cc:1213
void callException(const std::exception &) override
called when the job throws during an async call
Definition: client_side_request.cc:2078
Definition: HttpRequest.h:48
void clientStoreIdStart()
Definition: client_side_request.cc:774
void clientRedirectDone(const Helper::Reply &)
Definition: client_side_request.cc:1046
static void checkFailureRatio(err_type, hier_code)
Definition: client_side_request.cc:179
void clearRequest()
resets the current request and log_uri to nil
Definition: client_side_request.cc:1584
Definition: AsyncJobCalls.h:91
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
Definition: gadgets.cc:18
Definition: StoreIOBuffer.h:15
void CSD(clientStreamNode *, ClientHttpRequest *)
client stream detach
Definition: clientStreamForward.h:33
void CSR(clientStreamNode *, ClientHttpRequest *)
client stream read
Definition: clientStreamForward.h:30
Definition: client_side_request.h:30
char ThisCache2[RFC2181_MAXHOSTNAMELEN<< 1]
void stopConsumingFrom(RefCount< BodyPipe > &)
Definition: BodyPipe.cc:118
iterates services in ServiceGroup, starting adaptation launchers
Definition: Iterator.h:31
int64_t request_satisfaction_offset
Definition: client_side_request.h:250
void recordLookup(const Dns::LookupDetails &detail)
Definition: HttpRequest.cc:580
struct SquidConfig::UrlHelperTimeout onUrlRewriteTimeout
bool sslBumpAccessCheck()
Definition: client_side_request.cc:1246
Definition: client_side.h:79
void clearAdaptation(CbcPointer< Initiate > &x)
clears the pointer (does not call announceInitiatorAbort)
Definition: Initiator.cc:32
SBuf StringToSBuf(const String &s)
create a new SBuf from a String by copying contents
Definition: StringConvert.h:17
Definition: CommCalls.h:113
void ipcache_nbgethostbyname(const char *name, IPH *handler, void *handlerData)
Definition: ipcache.cc:609
Definition: RequestMethod.h:26
static void NonBlockingCheck(MakingPointer &&p, ACLCB *cb, void *data)
Definition: FilledChecklist.h:54
int refresh_nocache_hack
Definition: Reply.h:29
Adaptation::Icap::History::Pointer icapHistory() const
Returns possibly nil history, creating it if icap logging is enabled.
Definition: HttpRequest.cc:389
CommCbFunPtrCallT< Dialer > * commCbCall(int debugSection, int debugLevel, const char *callName, const Dialer &dialer)
Definition: CommCalls.h:312
int neighbors_do_private_keys
void noteMoreBodyDataAvailable(BodyPipe::Pointer) override
Definition: client_side_request.cc:1957
Definition: SquidString.h:25
void clientStoreIdDone(const Helper::Reply &)
Definition: client_side_request.cc:1162
void hostHeaderVerifyFailed(const char *A, const char *B)
Definition: client_side_request.cc:413
const HeaderTableRecord & lookup(const char *buf, const std::size_t len) const
look record type up by name (C-string and length)
Definition: RegisteredHeaders.cc:32
bool interpreted_req_hdrs
Definition: ClientRequestContext.h:77
void Write(const Comm::ConnectionPointer &conn, const char *buf, int size, AsyncCall::Pointer &callback, FREE *free_func)
Definition: Write.cc:33
size_t currentXffHopNumber
number of X-Forwarded-For header values processed so far
Definition: ClientRequestContext.h:87
size_t bytesWanted(Range< size_t > const aRange, bool ignoreDelayPool=false) const
Definition: store.cc:213
Definition: forward.h:15
StoreEntry * storeCreateEntry(const char *url, const char *logUrl, const RequestFlags &flags, const HttpRequestMethod &method)
Definition: store.cc:759
void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer) override
Definition: client_side_request.cc:693
bool host_header_verify_done
Definition: ClientRequestContext.h:68
void completeSuccessfully(const char *whyWeAreSureWeStoredTheWholeReply)
Definition: store.cc:1017
bool toClientMarkingDone
Definition: ClientRequestContext.h:78
Definition: ServerBump.h:33
summarizes adaptation service answer for the noteAdaptationAnswer() API
Definition: Answer.h:24
Definition: client_side_reply.h:22
const LogTags & loggingTags() const
the processing tags associated with this request transaction.
Definition: client_side_request.h:94
int strListIsSubstr(const String *list, const char *s, char del)
Definition: StrList.cc:63
void veto()
makes decision() false regardless of past or future support() calls
Definition: SupportOrVeto.h:29
void sslBumpEstablish(Comm::Flag)
Definition: client_side_request.cc:1418
struct SquidConfig::@91 Accel
const HeaderLookupTable_t HeaderLookupTable
Definition: RegisteredHeaders.cc:60
void sslBumpAccessCheckDone(const Acl::Answer &answer)
The callback function for ssl-bump access check list.
Definition: client_side_request.cc:1331
bool adaptation_acl_check_done
Definition: ClientRequestContext.h:72
void switchToHttps(ClientHttpRequest *, Ssl::BumpMode bumpServerMode)
Definition: client_side.cc:2772
void expectNoForwarding()
cleans up virgin request [body] forwarding state
Definition: client_side.cc:3571
tos_t aclMapTOS(acl_tos *head, ACLChecklist *ch)
Checks for a TOS value to apply depending on the ACL.
Definition: FwdState.cc:1458
const Auth::UserRequest::Pointer & getAuth() const
Definition: client_side.h:123
Definition: HttpReply.h:24
struct ConnStateData::@36 pinning
Ssl::BumpMode sslBumpNeed_
whether (and how) the request needs to be bumped
Definition: client_side_request.h:205
void checkNoCacheDone(const Acl::Answer &)
Definition: client_side_request.cc:1236
static void checkNoCacheDoneWrapper(Acl::Answer, void *)
Definition: client_side_request.cc:1225
void fvdbCountForwarded(const SBuf &)
count occurrences of the given X-Forwarded-For header value
const char * denyMessage(char const *const default_message=nullptr) const
Definition: UserRequest.cc:127
Definition: Store.h:37
bool setNfConnmark(Comm::ConnectionPointer &conn, const ConnectionDirection connDir, const NfMarkConfig &cm)
static void clientRedirectAccessCheckDone(Acl::Answer answer, void *data)
Definition: client_side_request.cc:724
void noteBodyProducerAborted(BodyPipe::Pointer) override
Definition: client_side_request.cc:2031
void handleAdaptedHeader(Http::Message *)
Definition: client_side_request.cc:1897
void resumeBodyStorage()
called by StoreEntry when it has more buffer space available
Definition: client_side_request.cc:1948
Definition: ClientRequestContext.h:28
Acl::Answer blockedToChecklistAnswer() const
creates an Acl::Answer from akBlock answer
Definition: Answer.cc:44
Error bareError
a problem that occurred without a request (e.g., while parsing headers)
Definition: client_side.h:381
ErrorState * clientBuildError(err_type, Http::StatusCode, char const *url, const ConnStateData *, HttpRequest *, const AccessLogEntry::Pointer &)
Definition: client_side_reply.cc:2117
void announceInitiatorAbort(CbcPointer< Initiate > &x)
inform the transaction about abnormal termination and clear the pointer
Definition: Initiator.cc:38
void handleAdaptationBlock(const Adaptation::Answer &)
Definition: client_side_request.cc:1939
Ip::NfMarkConfig aclFindNfMarkConfig(acl_nfmark *head, ACLChecklist *ch)
Checks for a netfilter mark value to apply depending on the ACL.
Definition: FwdState.cc:1470
size_t req_sz
raw request size on input, not current request size
Definition: client_side_request.h:159
void redirectStart(ClientHttpRequest *http, HLPCB *handler, void *data)
Definition: redirect.cc:286
static void clientCheckPinning(ClientHttpRequest *http)
Definition: client_side_request.cc:826
static HttpReplyPointer MakeConnectionEstablished()
construct and return an HTTP/200 (Connection Established) response
Definition: HttpReply.cc:121
~ClientRequestContext() override
Definition: client_side_request.cc:107
AnyP::Port port
destination port of the request that caused serverConnection
Definition: client_side.h:145
~ClientHttpRequest() override
Definition: client_side_request.cc:235
std::optional< SBuf > lastCheckedName
the name of the ACL (if any) that was evaluated last while obtaining this answer
Definition: Acl.h:105
CbcPointer< Adaptation::Initiate > virginHeadSource
Definition: client_side_request.h:243
void setLogUriToRequestUri()
sets log_uri when we know the current request
Definition: client_side_request.cc:1786
int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos)
Definition: QosConfig.cc:557
bool conflicted() const
whether Squid is uncertain about the allowed() or denied() answer
Definition: Acl.h:91
void calloutsError(const err_type, const ErrorDetail::Pointer &)
Build an error reply. For use with the callouts.
Definition: client_side_request.cc:2096
void storeIdStart(ClientHttpRequest *http, HLPCB *handler, void *data)
Definition: redirect.cc:312
void update(const Error &)
if necessary, stores the given error information (if any)
Definition: Error.cc:51
bool receivedWholeAdaptedReply
noteBodyProductionEnded() was called
Definition: client_side_request.h:247
char * urlCanonicalCleanWithoutRequest(const SBuf &url, const HttpRequestMethod &method, const AnyP::UriScheme &scheme)
Definition: Uri.cc:747
Ssl::BumpMode sslBumpNeed() const
returns raw sslBump mode value
Definition: client_side_request.h:195
ClientRequestContext * calloutContext
Definition: client_side_request.h:176
static void SslBumpEstablish(const Comm::ConnectionPointer &, char *, size_t, Comm::Flag errflag, int, void *data)
Definition: client_side_request.cc:1408
Definition: errorpage.h:88
static void sslBumpAccessCheckDoneWrapper(Acl::Answer, void *)
Definition: client_side_request.cc:1321
void deferProducer(const AsyncCall::Pointer &producer)
call back producer when more buffer space is available
Definition: store.cc:366
void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm)
Definition: tools.cc:938
static void clientStoreIdAccessCheckDone(Acl::Answer answer, void *data)
Definition: client_side_request.cc:754
StoreEntry * loggingEntry() const
Definition: client_side_request.h:65
HttpHeaderEntry * getEntry(HttpHeaderPos *pos) const
Definition: HttpHeader.cc:583
void setScheme(const AnyP::ProtocolType &p, const char *str)
convert the URL scheme to that given
Definition: Uri.h:61
void consume(mb_size_t sz)
removes sz bytes and "packs" by moving content left
Definition: MemBuf.cc:168
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:744
void updateError(const Error &)
if necessary, stores new error information (if any)
Definition: client_side_request.cc:1470
void absorbLogUri(char *)
assigns log_uri with aUri without copying the entire C-string
Definition: client_side_request.cc:1810
Definition: BodyPipe.h:61
Definition: CommCalls.h:229
Definition: Address.h:42
bool forceTunnel
whether to forward via TunnelStateData (instead of FwdState)
Definition: RequestFlags.h:120
static void clientInterpretRequestHeaders(ClientHttpRequest *http)
Definition: client_side_request.cc:887
void completeTruncated(const char *whyWeConsiderTheReplyTruncated)
Definition: store.cc:1024
Auth::UserRequest::Pointer auth_user_request
Definition: errorpage.h:175
Definition: HttpHeader.h:74
CbcPointer< ConnStateData > clientConnectionManager
Definition: HttpRequest.h:232
static bool Start(Method method, VectPoint vp, HttpRequest *req, HttpReply *, const AccessLogEntryPointer &, Adaptation::Initiator *)
Definition: AccessCheck.cc:30
void UpdateRequestNotes(ConnStateData *csd, HttpRequest &request, NotePairs const &helperNotes)
Definition: HttpRequest.cc:760
ErrorDetail::Pointer MakeNamedErrorDetail(const char *name)
Definition: Detail.cc:54
BodyPipe::Pointer adaptedBodySource
Definition: client_side_request.h:244
Introduction
- About Squid
- Why Squid?
- Squid Developers
- How to Donate
- How to Help Out
- Getting Squid
- Squid Source Packages
- Squid Deployment Case-Studies
- Squid Software Foundation
Documentation
- Quick Setup
- Configuration:
- FAQ and Wiki
- Guide Books:
- Non-English
- More...
Support
- Security Advisories
- Bugzilla Database
- Mailing lists
- Contacting us
- Commercial services
- Project Sponsors
- Squid-based products