2 * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 85 Client-side Request Routines */
12 * General logic of request processing:
14 * We run a series of tests to determine if access will be permitted, and to do
15 * any redirection. Then we call into the result clientStream to retrieve data.
16 * From that point on it's up to reply management.
20 #include "acl/FilledChecklist.h"
21 #include "acl/Gadgets.h"
22 #include "anyp/PortCfg.h"
23 #include "base/AsyncJobCalls.h"
24 #include "client_side.h"
25 #include "client_side_reply.h"
26 #include "client_side_request.h"
27 #include "ClientRequestContext.h"
28 #include "clientStream.h"
29 #include "comm/Connection.h"
30 #include "comm/Write.h"
31 #include "err_detail_type.h"
32 #include "errorpage.h"
35 #include "format/Token.h"
38 #include "helper/Reply.h"
40 #include "http/Stream.h"
41 #include "HttpHdrCc.h"
42 #include "HttpReply.h"
43 #include "HttpRequest.h"
44 #include "ip/QosConfig.h"
46 #include "log/access_log.h"
47 #include "MemObject.h"
49 #include "profiler/Profiler.h"
51 #include "SquidConfig.h"
52 #include "SquidTime.h"
59 #include "auth/UserRequest.h"
62 #include "adaptation/AccessCheck.h"
63 #include "adaptation/Answer.h"
64 #include "adaptation/Iterator.h"
65 #include "adaptation/Service.h"
67 #include "adaptation/icap/History.h"
71 #include "ssl/ServerBump.h"
72 #include "ssl/support.h"
76 #define comm_close comm_lingering_close
79 static const char *const crlf
= "\r\n";
81 #if FOLLOW_X_FORWARDED_FOR
82 static void clientFollowXForwardedForCheck(allow_t answer
, void *data
);
83 #endif /* FOLLOW_X_FORWARDED_FOR */
85 ErrorState
*clientBuildError(err_type
, Http::StatusCode
, char const *url
, Ip::Address
&, HttpRequest
*);
87 CBDATA_CLASS_INIT(ClientRequestContext
);
91 static void clientAccessCheckDoneWrapper(allow_t
, void *);
93 static void sslBumpAccessCheckDoneWrapper(allow_t
, void *);
95 static int clientHierarchical(ClientHttpRequest
* http
);
96 static void clientInterpretRequestHeaders(ClientHttpRequest
* http
);
97 static HLPCB clientRedirectDoneWrapper
;
98 static HLPCB clientStoreIdDoneWrapper
;
99 static void checkNoCacheDoneWrapper(allow_t
, void *);
100 SQUIDCEXTERN CSR clientGetMoreData
;
101 SQUIDCEXTERN CSS clientReplyStatus
;
102 SQUIDCEXTERN CSD clientReplyDetach
;
103 static void checkFailureRatio(err_type
, hier_code
);
105 ClientRequestContext::~ClientRequestContext()
108 * Release our "lock" on our parent, ClientHttpRequest, if we
113 cbdataReferenceDone(http
);
116 debugs(85,3, "ClientRequestContext destructed, this=" << this);
119 ClientRequestContext::ClientRequestContext(ClientHttpRequest
*anHttp
) :
120 http(cbdataReference(anHttp
)),
122 redirect_state(REDIRECT_NONE
),
123 store_id_state(REDIRECT_NONE
),
124 host_header_verify_done(false),
125 http_access_done(false),
126 adapted_http_access_done(false),
128 adaptation_acl_check_done(false),
130 redirect_done(false),
131 store_id_done(false),
132 no_cache_done(false),
133 interpreted_req_hdrs(false),
134 tosToClientDone(false),
135 nfmarkToClientDone(false),
137 sslBumpCheckDone(false),
140 readNextRequest(false)
142 debugs(85, 3, "ClientRequestContext constructed, this=" << this);
145 CBDATA_CLASS_INIT(ClientHttpRequest
);
147 ClientHttpRequest::ClientHttpRequest(ConnStateData
* aConn
) :
149 AsyncJob("ClientHttpRequest"),
155 logType(LOG_TAG_NONE
),
156 calloutContext(NULL
),
157 maxReplyBodySize_(0),
162 , sslBumpNeed_(Ssl::bumpEnd
)
165 , request_satisfaction_mode(false)
166 , request_satisfaction_offset(0)
170 al
= new AccessLogEntry
;
171 al
->cache
.start_time
= current_time
;
173 al
->tcpClient
= clientConnection
= aConn
->clientConnection
;
174 al
->cache
.port
= aConn
->port
;
175 al
->cache
.caddr
= aConn
->log_addr
;
178 if (aConn
->clientConnection
!= NULL
&& aConn
->clientConnection
->isOpen()) {
179 if (auto ssl
= fd_table
[aConn
->clientConnection
->fd
].ssl
.get())
180 al
->cache
.sslClientCert
.resetWithoutLocking(SSL_get_peer_certificate(ssl
));
184 dlinkAdd(this, &active
, &ClientActiveRequests
);
188 * returns true if client specified that the object must come from the cache
189 * without contacting origin server
192 ClientHttpRequest::onlyIfCached()const
195 return request
->cache_control
&&
196 request
->cache_control
->hasOnlyIfCached();
200 * This function is designed to serve a fairly specific purpose.
201 * Occasionally our vBNS-connected caches can talk to each other, but not
202 * the rest of the world. Here we try to detect frequent failures which
203 * make the cache unusable (e.g. DNS lookup and connect() failures). If
204 * the failure:success ratio goes above 1.0 then we go into "hit only"
205 * mode where we only return UDP_HIT or UDP_MISS_NOFETCH. Neighbors
206 * will only fetch HITs from us if they are using the ICP protocol. We
207 * stay in this mode for 5 minutes.
209 * Duane W., Sept 16, 1996
212 checkFailureRatio(err_type etype
, hier_code hcode
)
214 // Can be set at compile time with -D compiler flag
215 #ifndef FAILURE_MODE_TIME
216 #define FAILURE_MODE_TIME 300
219 if (hcode
== HIER_NONE
)
222 // don't bother when ICP is disabled.
223 if (Config
.Port
.icp
<= 0)
226 static double magic_factor
= 100.0;
230 n_good
= magic_factor
/ (1.0 + request_failure_ratio
);
232 n_bad
= magic_factor
- n_good
;
238 case ERR_CONNECT_FAIL
:
239 case ERR_SECURE_CONNECT_FAIL
:
249 request_failure_ratio
= n_bad
/ n_good
;
251 if (hit_only_mode_until
> squid_curtime
)
254 if (request_failure_ratio
< 1.0)
257 debugs(33, DBG_CRITICAL
, "WARNING: Failure Ratio at "<< std::setw(4)<<
258 std::setprecision(3) << request_failure_ratio
);
260 debugs(33, DBG_CRITICAL
, "WARNING: ICP going into HIT-only mode for " <<
261 FAILURE_MODE_TIME
/ 60 << " minutes...");
263 hit_only_mode_until
= squid_curtime
+ FAILURE_MODE_TIME
;
265 request_failure_ratio
= 0.8; /* reset to something less than 1.0 */
268 ClientHttpRequest::~ClientHttpRequest()
270 debugs(33, 3, "httpRequestFree: " << uri
);
271 PROF_start(httpRequestFree
);
273 // Even though freeResources() below may destroy the request,
274 // we no longer set request->body_pipe to NULL here
275 // because we did not initiate that pipe (ConnStateData did)
277 /* the ICP check here was erroneous
278 * - StoreEntry::releaseRequest was always called if entry was valid
286 checkFailureRatio(request
->errType
, al
->hier
.code
);
291 announceInitiatorAbort(virginHeadSource
);
293 if (adaptedBodySource
!= NULL
)
294 stopConsumingFrom(adaptedBodySource
);
298 delete calloutContext
;
300 clientConnection
= NULL
;
303 cbdataReferenceDone(conn_
);
305 /* moving to the next connection is handled by the context free */
306 dlinkDelete(&active
, &ClientActiveRequests
);
308 PROF_stop(httpRequestFree
);
312 * Create a request and kick it off
317 * TODO: Pass in the buffers to be used in the inital Read request, as they are
318 * determined by the user
321 clientBeginRequest(const HttpRequestMethod
& method
, char const *url
, CSCB
* streamcallback
,
322 CSD
* streamdetach
, ClientStreamData streamdata
, HttpHeader
const *header
,
323 char *tailbuf
, size_t taillen
, const MasterXaction::Pointer
&mx
)
326 ClientHttpRequest
*http
= new ClientHttpRequest(NULL
);
327 HttpRequest
*request
;
328 StoreIOBuffer tempBuffer
;
329 if (http
->al
!= NULL
)
330 http
->al
->cache
.start_time
= current_time
;
331 /* this is only used to adjust the connection offset in client_side.c */
333 tempBuffer
.length
= taillen
;
334 tempBuffer
.data
= tailbuf
;
335 /* client stream setup */
336 clientStreamInit(&http
->client_stream
, clientGetMoreData
, clientReplyDetach
,
337 clientReplyStatus
, new clientReplyContext(http
), streamcallback
,
338 streamdetach
, streamdata
, tempBuffer
);
339 /* make it visible in the 'current acctive requests list' */
341 /* internal requests only makes sense in an
342 * accelerator today. TODO: accept flags ? */
343 http
->flags
.accel
= true;
344 /* allow size for url rewriting */
345 url_sz
= strlen(url
) + Config
.appendDomainLen
+ 5;
346 http
->uri
= (char *)xcalloc(url_sz
, 1);
347 strcpy(http
->uri
, url
); // XXX: polluting http->uri before parser validation
349 if ((request
= HttpRequest::FromUrl(http
->uri
, mx
, method
)) == NULL
) {
350 debugs(85, 5, "Invalid URL: " << http
->uri
);
355 * now update the headers in request with our supplied headers.
356 * HttpRequest::FromUrl() should return a blank header set, but
357 * we use Update to be sure of correctness.
360 request
->header
.update(header
);
362 http
->log_uri
= xstrdup(urlCanonicalClean(request
));
364 /* http struct now ready */
367 * build new header list *? TODO
369 request
->flags
.accelerated
= http
->flags
.accel
;
371 /* this is an internally created
372 * request, not subject to acceleration
373 * target overrides */
375 * FIXME? Do we want to detect and handle internal requests of internal
379 /* Internally created requests cannot have bodies today */
380 request
->content_length
= 0;
382 request
->client_addr
.setNoAddr();
384 #if FOLLOW_X_FORWARDED_FOR
385 request
->indirect_client_addr
.setNoAddr();
386 #endif /* FOLLOW_X_FORWARDED_FOR */
388 request
->my_addr
.setNoAddr(); /* undefined for internal requests */
390 request
->my_addr
.port(0);
392 request
->http_ver
= Http::ProtocolVersion();
394 http
->request
= request
;
395 HTTPMSGLOCK(http
->request
);
397 /* optional - skip the access check ? */
398 http
->calloutContext
= new ClientRequestContext(http
);
400 http
->calloutContext
->http_access_done
= false;
402 http
->calloutContext
->redirect_done
= true;
404 http
->calloutContext
->no_cache_done
= true;
412 ClientRequestContext::httpStateIsValid()
414 ClientHttpRequest
*http_
= http
;
416 if (cbdataReferenceValid(http_
))
421 cbdataReferenceDone(http_
);
426 #if FOLLOW_X_FORWARDED_FOR
428 * clientFollowXForwardedForCheck() checks the content of X-Forwarded-For:
429 * against the followXFF ACL, or cleans up and passes control to
430 * clientAccessCheck().
432 * The trust model here is a little ambiguous. So to clarify the logic:
433 * - we may always use the direct client address as the client IP.
434 * - these trust tests merey tell whether we trust given IP enough to believe the
435 * IP string which it appended to the X-Forwarded-For: header.
436 * - if at any point we don't trust what an IP adds we stop looking.
437 * - at that point the current contents of indirect_client_addr are the value set
438 * by the last previously trusted IP.
439 * ++ indirect_client_addr contains the remote direct client from the trusted peers viewpoint.
442 clientFollowXForwardedForCheck(allow_t answer
, void *data
)
444 ClientRequestContext
*calloutContext
= (ClientRequestContext
*) data
;
446 if (!calloutContext
->httpStateIsValid())
449 ClientHttpRequest
*http
= calloutContext
->http
;
450 HttpRequest
*request
= http
->request
;
452 if (answer
.allowed() && request
->x_forwarded_for_iterator
.size() != 0) {
455 * Remove the last comma-delimited element from the
456 * x_forwarded_for_iterator and use it to repeat the cycle.
459 const char *asciiaddr
;
462 p
= request
->x_forwarded_for_iterator
.termedBuf();
463 l
= request
->x_forwarded_for_iterator
.size();
466 * XXX x_forwarded_for_iterator should really be a list of
467 * IP addresses, but it's a String instead. We have to
468 * walk backwards through the String, biting off the last
469 * comma-delimited part each time. As long as the data is in
470 * a String, we should probably implement and use a variant of
471 * strListGetItem() that walks backwards instead of forwards
472 * through a comma-separated list. But we don't even do that;
473 * we just do the work in-line here.
475 /* skip trailing space and commas */
476 while (l
> 0 && (p
[l
-1] == ',' || xisspace(p
[l
-1])))
478 request
->x_forwarded_for_iterator
.cut(l
);
479 /* look for start of last item in list */
480 while (l
> 0 && ! (p
[l
-1] == ',' || xisspace(p
[l
-1])))
483 if ((addr
= asciiaddr
)) {
484 request
->indirect_client_addr
= addr
;
485 request
->x_forwarded_for_iterator
.cut(l
);
486 calloutContext
->acl_checklist
= clientAclChecklistCreate(Config
.accessList
.followXFF
, http
);
487 if (!Config
.onoff
.acl_uses_indirect_client
) {
488 /* override the default src_addr tested if we have to go deeper than one level into XFF */
489 Filled(calloutContext
->acl_checklist
)->src_addr
= request
->indirect_client_addr
;
491 calloutContext
->acl_checklist
->nonBlockingCheck(clientFollowXForwardedForCheck
, data
);
496 /* clean up, and pass control to clientAccessCheck */
497 if (Config
.onoff
.log_uses_indirect_client
) {
499 * Ensure that the access log shows the indirect client
500 * instead of the direct client.
502 ConnStateData
*conn
= http
->getConn();
503 conn
->log_addr
= request
->indirect_client_addr
;
504 http
->al
->cache
.caddr
= conn
->log_addr
;
506 request
->x_forwarded_for_iterator
.clean();
507 request
->flags
.done_follow_x_forwarded_for
= true;
509 if (answer
.conflicted()) {
510 debugs(28, DBG_CRITICAL
, "ERROR: Processing X-Forwarded-For. Stopping at IP address: " << request
->indirect_client_addr
);
513 /* process actual access ACL as normal. */
514 calloutContext
->clientAccessCheck();
516 #endif /* FOLLOW_X_FORWARDED_FOR */
519 hostHeaderIpVerifyWrapper(const ipcache_addrs
* ia
, const Dns::LookupDetails
&dns
, void *data
)
521 ClientRequestContext
*c
= static_cast<ClientRequestContext
*>(data
);
522 c
->hostHeaderIpVerify(ia
, dns
);
526 ClientRequestContext::hostHeaderIpVerify(const ipcache_addrs
* ia
, const Dns::LookupDetails
&dns
)
528 Comm::ConnectionPointer clientConn
= http
->getConn()->clientConnection
;
530 // note the DNS details for the transaction stats.
531 http
->request
->recordLookup(dns
);
533 // Is the NAT destination IP in DNS?
534 if (ia
&& ia
->have(clientConn
->local
)) {
535 debugs(85, 3, "validate IP " << clientConn
->local
<< " possible from Host:");
536 http
->request
->flags
.hostVerified
= true;
540 debugs(85, 3, HERE
<< "FAIL: validate IP " << clientConn
->local
<< " possible from Host:");
541 hostHeaderVerifyFailed("local IP", "any domain IP");
545 ClientRequestContext::hostHeaderVerifyFailed(const char *A
, const char *B
)
547 // IP address validation for Host: failed. Admin wants to ignore them.
548 // NP: we do not yet handle CONNECT tunnels well, so ignore for them
549 if (!Config
.onoff
.hostStrictVerify
&& http
->request
->method
!= Http::METHOD_CONNECT
) {
550 debugs(85, 3, "SECURITY ALERT: Host header forgery detected on " << http
->getConn()->clientConnection
<<
551 " (" << A
<< " does not match " << B
<< ") on URL: " << http
->request
->effectiveRequestUri());
553 // NP: it is tempting to use 'flags.noCache' but that is all about READing cache data.
554 // The problems here are about WRITE for new cache content, which means flags.cachable
555 http
->request
->flags
.cachable
= false; // MUST NOT cache (for now)
556 // XXX: when we have updated the cache key to base on raw-IP + URI this cacheable limit can go.
557 http
->request
->flags
.hierarchical
= false; // MUST NOT pass to peers (for now)
558 // XXX: when we have sorted out the best way to relay requests properly to peers this hierarchical limit can go.
563 debugs(85, DBG_IMPORTANT
, "SECURITY ALERT: Host header forgery detected on " <<
564 http
->getConn()->clientConnection
<< " (" << A
<< " does not match " << B
<< ")");
565 if (const char *ua
= http
->request
->header
.getStr(Http::HdrType::USER_AGENT
))
566 debugs(85, DBG_IMPORTANT
, "SECURITY ALERT: By user agent: " << ua
);
567 debugs(85, DBG_IMPORTANT
, "SECURITY ALERT: on URL: " << http
->request
->effectiveRequestUri());
569 // IP address validation for Host: failed. reject the connection.
570 clientStreamNode
*node
= (clientStreamNode
*)http
->client_stream
.tail
->prev
->data
;
571 clientReplyContext
*repContext
= dynamic_cast<clientReplyContext
*>(node
->data
.getRaw());
573 repContext
->setReplyToError(ERR_CONFLICT_HOST
, Http::scConflict
,
574 http
->request
->method
, NULL
,
575 http
->getConn()->clientConnection
->remote
,
579 http
->getConn() != NULL
&& http
->getConn()->getAuth() != NULL
?
580 http
->getConn()->getAuth() : http
->request
->auth_user_request
);
584 node
= (clientStreamNode
*)http
->client_stream
.tail
->data
;
585 clientStreamRead(node
, http
, node
->readBuffer
);
589 ClientRequestContext::hostHeaderVerify()
591 // Require a Host: header.
592 const char *host
= http
->request
->header
.getStr(Http::HdrType::HOST
);
595 // TODO: dump out the HTTP/1.1 error about missing host header.
596 // otherwise this is fine, can't forge a header value when its not even set.
597 debugs(85, 3, HERE
<< "validate skipped with no Host: header present.");
602 if (http
->request
->flags
.internal
) {
603 // TODO: kill this when URL handling allows partial URLs out of accel mode
604 // and we no longer screw with the URL just to add our internal host there
605 debugs(85, 6, HERE
<< "validate skipped due to internal composite URL.");
610 // Locate if there is a port attached, strip ready for IP lookup
611 char *portStr
= NULL
;
612 char *hostB
= xstrdup(host
);
614 if (host
[0] == '[') {
616 portStr
= strchr(hostB
, ']');
617 if (portStr
&& *(++portStr
) != ':') {
621 // Domain or IPv4 literal with port
622 portStr
= strrchr(hostB
, ':');
627 *portStr
= '\0'; // strip the ':'
628 if (*(++portStr
) != '\0') {
630 int64_t ret
= strtoll(portStr
, &end
, 10);
631 if (end
== portStr
|| *end
!= '\0' || ret
< 1 || ret
> 0xFFFF) {
632 // invalid port details. Replace the ':'
636 port
= (ret
& 0xFFFF);
640 debugs(85, 3, "validate host=" << host
<< ", port=" << port
<< ", portStr=" << (portStr
?portStr
:"NULL"));
641 if (http
->request
->flags
.intercepted
|| http
->request
->flags
.interceptTproxy
) {
642 // verify the Host: port (if any) matches the apparent destination
643 if (portStr
&& port
!= http
->getConn()->clientConnection
->local
.port()) {
644 debugs(85, 3, "FAIL on validate port " << http
->getConn()->clientConnection
->local
.port() <<
645 " matches Host: port " << port
<< " (" << portStr
<< ")");
646 hostHeaderVerifyFailed("intercepted port", portStr
);
648 // XXX: match the scheme default port against the apparent destination
650 // verify the destination DNS is one of the Host: headers IPs
651 ipcache_nbgethostbyname(host
, hostHeaderIpVerifyWrapper
, this);
653 } else if (!Config
.onoff
.hostStrictVerify
) {
654 debugs(85, 3, "validate skipped.");
656 } else if (strlen(host
) != strlen(http
->request
->url
.host())) {
657 // Verify forward-proxy requested URL domain matches the Host: header
658 debugs(85, 3, "FAIL on validate URL domain length " << http
->request
->url
.host() << " matches Host: " << host
);
659 hostHeaderVerifyFailed(host
, http
->request
->url
.host());
660 } else if (matchDomainName(host
, http
->request
->url
.host()) != 0) {
661 // Verify forward-proxy requested URL domain matches the Host: header
662 debugs(85, 3, "FAIL on validate URL domain " << http
->request
->url
.host() << " matches Host: " << host
);
663 hostHeaderVerifyFailed(host
, http
->request
->url
.host());
664 } else if (portStr
&& port
!= http
->request
->url
.port()) {
665 // Verify forward-proxy requested URL domain matches the Host: header
666 debugs(85, 3, "FAIL on validate URL port " << http
->request
->url
.port() << " matches Host: port " << portStr
);
667 hostHeaderVerifyFailed("URL port", portStr
);
668 } else if (!portStr
&& http
->request
->method
!= Http::METHOD_CONNECT
&& http
->request
->url
.port() != http
->request
->url
.getScheme().defaultPort()) {
669 // Verify forward-proxy requested URL domain matches the Host: header
670 // Special case: we don't have a default-port to check for CONNECT. Assume URL is correct.
671 debugs(85, 3, "FAIL on validate URL port " << http
->request
->url
.port() << " matches Host: default port " << http
->request
->url
.getScheme().defaultPort());
672 hostHeaderVerifyFailed("URL port", "default port");
675 debugs(85, 3, "validate passed.");
676 http
->request
->flags
.hostVerified
= true;
682 /* This is the entry point for external users of the client_side routines */
684 ClientRequestContext::clientAccessCheck()
686 #if FOLLOW_X_FORWARDED_FOR
687 if (!http
->request
->flags
.doneFollowXff() &&
688 Config
.accessList
.followXFF
&&
689 http
->request
->header
.has(Http::HdrType::X_FORWARDED_FOR
)) {
691 /* we always trust the direct client address for actual use */
692 http
->request
->indirect_client_addr
= http
->request
->client_addr
;
693 http
->request
->indirect_client_addr
.port(0);
695 /* setup the XFF iterator for processing */
696 http
->request
->x_forwarded_for_iterator
= http
->request
->header
.getList(Http::HdrType::X_FORWARDED_FOR
);
698 /* begin by checking to see if we trust direct client enough to walk XFF */
699 acl_checklist
= clientAclChecklistCreate(Config
.accessList
.followXFF
, http
);
700 acl_checklist
->nonBlockingCheck(clientFollowXForwardedForCheck
, this);
705 if (Config
.accessList
.http
) {
706 acl_checklist
= clientAclChecklistCreate(Config
.accessList
.http
, http
);
707 acl_checklist
->nonBlockingCheck(clientAccessCheckDoneWrapper
, this);
709 debugs(0, DBG_CRITICAL
, "No http_access configuration found. This will block ALL traffic");
710 clientAccessCheckDone(ACCESS_DENIED
);
715 * Identical in operation to clientAccessCheck() but performed later using different configured ACL list.
716 * The default here is to allow all. Since the earlier http_access should do a default deny all.
717 * This check is just for a last-minute denial based on adapted request headers.
720 ClientRequestContext::clientAccessCheck2()
722 if (Config
.accessList
.adapted_http
) {
723 acl_checklist
= clientAclChecklistCreate(Config
.accessList
.adapted_http
, http
);
724 acl_checklist
->nonBlockingCheck(clientAccessCheckDoneWrapper
, this);
726 debugs(85, 2, HERE
<< "No adapted_http_access configuration. default: ALLOW");
727 clientAccessCheckDone(ACCESS_ALLOWED
);
732 clientAccessCheckDoneWrapper(allow_t answer
, void *data
)
734 ClientRequestContext
*calloutContext
= (ClientRequestContext
*) data
;
736 if (!calloutContext
->httpStateIsValid())
739 calloutContext
->clientAccessCheckDone(answer
);
743 ClientRequestContext::clientAccessCheckDone(const allow_t
&answer
)
745 acl_checklist
= NULL
;
747 Http::StatusCode status
;
748 debugs(85, 2, "The request " << http
->request
->method
<< ' ' <<
749 http
->uri
<< " is " << answer
<<
750 "; last ACL checked: " << (AclMatchedName
? AclMatchedName
: "[none]"));
753 char const *proxy_auth_msg
= "<null>";
754 if (http
->getConn() != NULL
&& http
->getConn()->getAuth() != NULL
)
755 proxy_auth_msg
= http
->getConn()->getAuth()->denyMessage("<null>");
756 else if (http
->request
->auth_user_request
!= NULL
)
757 proxy_auth_msg
= http
->request
->auth_user_request
->denyMessage("<null>");
760 if (!answer
.allowed()) {
761 // auth has a grace period where credentials can be expired but okay not to challenge.
763 /* Send an auth challenge or error */
764 // XXX: do we still need aclIsProxyAuth() ?
765 bool auth_challenge
= (answer
== ACCESS_AUTH_REQUIRED
|| aclIsProxyAuth(AclMatchedName
));
766 debugs(85, 5, "Access Denied: " << http
->uri
);
767 debugs(85, 5, "AclMatchedName = " << (AclMatchedName
? AclMatchedName
: "<null>"));
770 debugs(33, 5, "Proxy Auth Message = " << (proxy_auth_msg
? proxy_auth_msg
: "<null>"));
774 * NOTE: get page_id here, based on AclMatchedName because if
775 * USE_DELAY_POOLS is enabled, then AclMatchedName gets clobbered in
776 * the clientCreateStoreEntry() call just below. Pedro Ribeiro
779 page_id
= aclGetDenyInfoPage(&Config
.denyInfoList
, AclMatchedName
, answer
!= ACCESS_AUTH_REQUIRED
);
781 http
->logType
= LOG_TCP_DENIED
;
783 if (auth_challenge
) {
785 if (http
->request
->flags
.sslBumped
) {
786 /*SSL Bumped request, authentication is not possible*/
787 status
= Http::scForbidden
;
788 } else if (!http
->flags
.accel
) {
789 /* Proxy authorisation needed */
790 status
= Http::scProxyAuthenticationRequired
;
792 /* WWW authorisation needed */
793 status
= Http::scUnauthorized
;
796 // need auth, but not possible to do.
797 status
= Http::scForbidden
;
799 if (page_id
== ERR_NONE
)
800 page_id
= ERR_CACHE_ACCESS_DENIED
;
802 status
= Http::scForbidden
;
804 if (page_id
== ERR_NONE
)
805 page_id
= ERR_ACCESS_DENIED
;
808 Ip::Address tmpnoaddr
;
809 tmpnoaddr
.setNoAddr();
810 error
= clientBuildError(page_id
, status
,
812 http
->getConn() != NULL
? http
->getConn()->clientConnection
->remote
: tmpnoaddr
,
817 error
->auth_user_request
=
818 http
->getConn() != NULL
&& http
->getConn()->getAuth() != NULL
?
819 http
->getConn()->getAuth() : http
->request
->auth_user_request
;
822 readNextRequest
= true;
825 /* ACCESS_ALLOWED continues here ... */
827 http
->uri
= SBufToCstring(http
->request
->effectiveRequestUri());
833 ClientHttpRequest::noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer g
)
835 debugs(93,3,HERE
<< this << " adaptationAclCheckDone called");
838 Adaptation::Icap::History::Pointer ih
= request
->icapHistory();
840 if (getConn() != NULL
&& getConn()->clientConnection
!= NULL
) {
841 ih
->rfc931
= getConn()->clientConnection
->rfc931
;
843 if (getConn()->clientConnection
->isOpen()) {
844 ih
->ssluser
= sslGetUserEmail(fd_table
[getConn()->clientConnection
->fd
].ssl
.get());
848 ih
->log_uri
= log_uri
;
854 debugs(85,3, HERE
<< "no adaptation needed");
865 clientRedirectAccessCheckDone(allow_t answer
, void *data
)
867 ClientRequestContext
*context
= (ClientRequestContext
*)data
;
868 ClientHttpRequest
*http
= context
->http
;
869 context
->acl_checklist
= NULL
;
871 if (answer
.allowed())
872 redirectStart(http
, clientRedirectDoneWrapper
, context
);
874 Helper::Reply
const nilReply(Helper::Error
);
875 context
->clientRedirectDone(nilReply
);
880 ClientRequestContext::clientRedirectStart()
882 debugs(33, 5, HERE
<< "'" << http
->uri
<< "'");
883 http
->al
->syncNotes(http
->request
);
884 if (Config
.accessList
.redirector
) {
885 acl_checklist
= clientAclChecklistCreate(Config
.accessList
.redirector
, http
);
886 acl_checklist
->nonBlockingCheck(clientRedirectAccessCheckDone
, this);
888 redirectStart(http
, clientRedirectDoneWrapper
, this);
892 * This methods handles Access checks result of StoreId access list.
893 * Will handle as "ERR" (no change) in a case Access is not allowed.
896 clientStoreIdAccessCheckDone(allow_t answer
, void *data
)
898 ClientRequestContext
*context
= static_cast<ClientRequestContext
*>(data
);
899 ClientHttpRequest
*http
= context
->http
;
900 context
->acl_checklist
= NULL
;
902 if (answer
.allowed())
903 storeIdStart(http
, clientStoreIdDoneWrapper
, context
);
905 debugs(85, 3, "access denied expected ERR reply handling: " << answer
);
906 Helper::Reply
const nilReply(Helper::Error
);
907 context
->clientStoreIdDone(nilReply
);
912 * Start locating an alternative storeage ID string (if any) from admin
913 * configured helper program. This is an asynchronous operation terminating in
914 * ClientRequestContext::clientStoreIdDone() when completed.
917 ClientRequestContext::clientStoreIdStart()
919 debugs(33, 5,"'" << http
->uri
<< "'");
921 if (Config
.accessList
.store_id
) {
922 acl_checklist
= clientAclChecklistCreate(Config
.accessList
.store_id
, http
);
923 acl_checklist
->nonBlockingCheck(clientStoreIdAccessCheckDone
, this);
925 storeIdStart(http
, clientStoreIdDoneWrapper
, this);
929 clientHierarchical(ClientHttpRequest
* http
)
931 HttpRequest
*request
= http
->request
;
932 HttpRequestMethod method
= request
->method
;
934 // intercepted requests MUST NOT (yet) be sent to peers unless verified
935 if (!request
->flags
.hostVerified
&& (request
->flags
.intercepted
|| request
->flags
.interceptTproxy
))
939 * IMS needs a private key, so we can use the hierarchy for IMS only if our
940 * neighbors support private keys
943 if (request
->flags
.ims
&& !neighbors_do_private_keys
)
947 * This is incorrect: authenticating requests can be sent via a hierarchy
948 * (they can even be cached if the correct headers are set on the reply)
950 if (request
->flags
.auth
)
953 if (method
== Http::METHOD_TRACE
)
956 if (method
!= Http::METHOD_GET
)
959 if (request
->flags
.loopDetected
)
962 if (request
->url
.getScheme() == AnyP::PROTO_HTTP
)
963 return method
.respMaybeCacheable();
965 if (request
->url
.getScheme() == AnyP::PROTO_GOPHER
)
966 return gopherCachable(request
);
968 if (request
->url
.getScheme() == AnyP::PROTO_CACHE_OBJECT
)
975 clientCheckPinning(ClientHttpRequest
* http
)
977 HttpRequest
*request
= http
->request
;
978 HttpHeader
*req_hdr
= &request
->header
;
979 ConnStateData
*http_conn
= http
->getConn();
981 /* Internal requests such as those from ESI includes may be without
982 * a client connection
987 request
->flags
.connectionAuthDisabled
= http_conn
->port
->connection_auth_disabled
;
988 if (!request
->flags
.connectionAuthDisabled
) {
989 if (Comm::IsConnOpen(http_conn
->pinning
.serverConnection
)) {
990 if (http_conn
->pinning
.auth
) {
991 request
->flags
.connectionAuth
= true;
992 request
->flags
.auth
= true;
994 request
->flags
.connectionProxyAuth
= true;
996 // These should already be linked correctly.
997 assert(request
->clientConnectionManager
== http_conn
);
1001 /* check if connection auth is used, and flag as candidate for pinning
1003 * Note: we may need to set flags.connectionAuth even if the connection
1004 * is already pinned if it was pinned earlier due to proxy auth
1006 if (!request
->flags
.connectionAuth
) {
1007 if (req_hdr
->has(Http::HdrType::AUTHORIZATION
) || req_hdr
->has(Http::HdrType::PROXY_AUTHORIZATION
)) {
1008 HttpHeaderPos pos
= HttpHeaderInitPos
;
1011 while ((e
= req_hdr
->getEntry(&pos
))) {
1012 if (e
->id
== Http::HdrType::AUTHORIZATION
|| e
->id
== Http::HdrType::PROXY_AUTHORIZATION
) {
1013 const char *value
= e
->value
.rawBuf();
1014 if (strncasecmp(value
, "NTLM ", 5) == 0
1016 strncasecmp(value
, "Negotiate ", 10) == 0
1018 strncasecmp(value
, "Kerberos ", 9) == 0) {
1019 if (e
->id
== Http::HdrType::AUTHORIZATION
) {
1020 request
->flags
.connectionAuth
= true;
1023 request
->flags
.connectionProxyAuth
= true;
1029 if (may_pin
&& !request
->pinnedConnection()) {
1030 // These should already be linked correctly. Just need the ServerConnection to pinn.
1031 assert(request
->clientConnectionManager
== http_conn
);
1038 clientInterpretRequestHeaders(ClientHttpRequest
* http
)
1040 HttpRequest
*request
= http
->request
;
1041 HttpHeader
*req_hdr
= &request
->header
;
1042 bool no_cache
= false;
1044 request
->imslen
= -1;
1045 request
->ims
= req_hdr
->getTime(Http::HdrType::IF_MODIFIED_SINCE
);
1047 if (request
->ims
> 0)
1048 request
->flags
.ims
= true;
1050 if (!request
->flags
.ignoreCc
) {
1051 if (request
->cache_control
) {
1052 if (request
->cache_control
->hasNoCache())
1055 // RFC 2616: treat Pragma:no-cache as if it was Cache-Control:no-cache when Cache-Control is missing
1056 } else if (req_hdr
->has(Http::HdrType::PRAGMA
))
1057 no_cache
= req_hdr
->hasListMember(Http::HdrType::PRAGMA
,"no-cache",',');
1060 if (request
->method
== Http::METHOD_OTHER
) {
1065 #if USE_HTTP_VIOLATIONS
1067 if (Config
.onoff
.reload_into_ims
)
1068 request
->flags
.nocacheHack
= true;
1069 else if (refresh_nocache_hack
)
1070 request
->flags
.nocacheHack
= true;
1074 request
->flags
.noCache
= true;
1077 /* ignore range header in non-GETs or non-HEADs */
1078 if (request
->method
== Http::METHOD_GET
|| request
->method
== Http::METHOD_HEAD
) {
1079 // XXX: initialize if we got here without HttpRequest::parseHeader()
1080 if (!request
->range
)
1081 request
->range
= req_hdr
->getRange();
1083 if (request
->range
) {
1084 request
->flags
.isRanged
= true;
1085 clientStreamNode
*node
= (clientStreamNode
*)http
->client_stream
.tail
->data
;
1086 /* XXX: This is suboptimal. We should give the stream the range set,
1087 * and thereby let the top of the stream set the offset when the
1088 * size becomes known. As it is, we will end up requesting from 0
1089 * for evey -X range specification.
1090 * RBC - this may be somewhat wrong. We should probably set the range
1091 * iter up at this point.
1093 node
->readBuffer
.offset
= request
->range
->lowestOffset(0);
1094 http
->range_iter
.pos
= request
->range
->begin();
1095 http
->range_iter
.end
= request
->range
->end();
1096 http
->range_iter
.valid
= true;
1100 /* Only HEAD and GET requests permit a Range or Request-Range header.
1101 * If these headers appear on any other type of request, delete them now.
1104 req_hdr
->delById(Http::HdrType::RANGE
);
1105 req_hdr
->delById(Http::HdrType::REQUEST_RANGE
);
1106 request
->ignoreRange("neither HEAD nor GET");
1109 if (req_hdr
->has(Http::HdrType::AUTHORIZATION
))
1110 request
->flags
.auth
= true;
1112 clientCheckPinning(http
);
1114 if (!request
->url
.userInfo().isEmpty())
1115 request
->flags
.auth
= true;
1117 if (req_hdr
->has(Http::HdrType::VIA
)) {
1118 String s
= req_hdr
->getList(Http::HdrType::VIA
);
1120 * ThisCache cannot be a member of Via header, "1.1 ThisCache" can.
1121 * Note ThisCache2 has a space prepended to the hostname so we don't
1122 * accidentally match super-domains.
1125 if (strListIsSubstr(&s
, ThisCache2
, ',')) {
1126 debugObj(33, 1, "WARNING: Forwarding loop detected for:\n",
1127 request
, (ObjPackMethod
) & httpRequestPack
);
1128 request
->flags
.loopDetected
= true;
1132 fvdbCountVia(s
.termedBuf());
1141 if (req_hdr
->has(Http::HdrType::X_FORWARDED_FOR
)) {
1142 String s
= req_hdr
->getList(Http::HdrType::X_FORWARDED_FOR
);
1143 fvdbCountForw(s
.termedBuf());
1149 request
->flags
.cachable
= http
->request
->maybeCacheable();
1151 if (clientHierarchical(http
))
1152 request
->flags
.hierarchical
= true;
1154 debugs(85, 5, "clientInterpretRequestHeaders: REQ_NOCACHE = " <<
1155 (request
->flags
.noCache
? "SET" : "NOT SET"));
1156 debugs(85, 5, "clientInterpretRequestHeaders: REQ_CACHABLE = " <<
1157 (request
->flags
.cachable
? "SET" : "NOT SET"));
1158 debugs(85, 5, "clientInterpretRequestHeaders: REQ_HIERARCHICAL = " <<
1159 (request
->flags
.hierarchical
? "SET" : "NOT SET"));
1164 clientRedirectDoneWrapper(void *data
, const Helper::Reply
&result
)
1166 ClientRequestContext
*calloutContext
= (ClientRequestContext
*)data
;
1168 if (!calloutContext
->httpStateIsValid())
1171 calloutContext
->clientRedirectDone(result
);
1175 clientStoreIdDoneWrapper(void *data
, const Helper::Reply
&result
)
1177 ClientRequestContext
*calloutContext
= (ClientRequestContext
*)data
;
1179 if (!calloutContext
->httpStateIsValid())
1182 calloutContext
->clientStoreIdDone(result
);
1186 ClientRequestContext::clientRedirectDone(const Helper::Reply
&reply
)
1188 HttpRequest
*old_request
= http
->request
;
1189 debugs(85, 5, HERE
<< "'" << http
->uri
<< "' result=" << reply
);
1190 assert(redirect_state
== REDIRECT_PENDING
);
1191 redirect_state
= REDIRECT_DONE
;
1193 // Put helper response Notes into the transaction state record (ALE) eventually
1194 // do it early to ensure that no matter what the outcome the notes are present.
1196 http
->al
->syncNotes(old_request
);
1198 UpdateRequestNotes(http
->getConn(), *old_request
, reply
.notes
);
1200 switch (reply
.result
) {
1201 case Helper::TimedOut
:
1202 if (Config
.onUrlRewriteTimeout
.action
!= toutActBypass
) {
1203 http
->calloutsError(ERR_GATEWAY_FAILURE
, ERR_DETAIL_REDIRECTOR_TIMEDOUT
);
1204 debugs(85, DBG_IMPORTANT
, "ERROR: URL rewrite helper: Timedout");
1208 case Helper::Unknown
:
1210 // Handler in redirect.cc should have already mapped Unknown
1211 // IF it contained valid entry for the old URL-rewrite helper protocol
1212 debugs(85, DBG_IMPORTANT
, "ERROR: URL rewrite helper returned invalid result code. Wrong helper? " << reply
);
1215 case Helper::BrokenHelper
:
1216 debugs(85, DBG_IMPORTANT
, "ERROR: URL rewrite helper: " << reply
);
1220 // no change to be done.
1223 case Helper::Okay
: {
1224 // #1: redirect with a specific status code OK status=NNN url="..."
1225 // #2: redirect with a default status code OK url="..."
1226 // #3: re-write the URL OK rewrite-url="..."
1228 const char *statusNote
= reply
.notes
.findFirst("status");
1229 const char *urlNote
= reply
.notes
.findFirst("url");
1231 if (urlNote
!= NULL
) {
1232 // HTTP protocol redirect to be done.
1234 // TODO: change default redirect status for appropriate requests
1235 // Squid defaults to 302 status for now for better compatibility with old clients.
1236 // HTTP/1.0 client should get 302 (Http::scFound)
1237 // HTTP/1.1 client contacting reverse-proxy should get 307 (Http::scTemporaryRedirect)
1238 // HTTP/1.1 client being diverted by forward-proxy should get 303 (Http::scSeeOther)
1239 Http::StatusCode status
= Http::scFound
;
1240 if (statusNote
!= NULL
) {
1241 const char * result
= statusNote
;
1242 status
= static_cast<Http::StatusCode
>(atoi(result
));
1245 if (status
== Http::scMovedPermanently
1246 || status
== Http::scFound
1247 || status
== Http::scSeeOther
1248 || status
== Http::scPermanentRedirect
1249 || status
== Http::scTemporaryRedirect
) {
1250 http
->redirect
.status
= status
;
1251 http
->redirect
.location
= xstrdup(urlNote
);
1252 // TODO: validate the URL produced here is RFC 2616 compliant absolute URI
1254 debugs(85, DBG_CRITICAL
, "ERROR: URL-rewrite produces invalid " << status
<< " redirect Location: " << urlNote
);
1257 // URL-rewrite wanted. Ew.
1258 urlNote
= reply
.notes
.findFirst("rewrite-url");
1260 // prevent broken helpers causing too much damage. If old URL == new URL skip the re-write.
1261 if (urlNote
!= NULL
&& strcmp(urlNote
, http
->uri
)) {
1263 if (tmpUrl
.parse(old_request
->method
, urlNote
)) {
1264 HttpRequest
*new_request
= old_request
->clone();
1265 new_request
->url
= tmpUrl
;
1266 debugs(61, 2, "URL-rewriter diverts URL from " << old_request
->effectiveRequestUri() << " to " << new_request
->effectiveRequestUri());
1268 // update the new request to flag the re-writing was done on it
1269 new_request
->flags
.redirected
= true;
1271 // unlink bodypipe from the old request. Not needed there any longer.
1272 if (old_request
->body_pipe
!= NULL
) {
1273 old_request
->body_pipe
= NULL
;
1274 debugs(61,2, HERE
<< "URL-rewriter diverts body_pipe " << new_request
->body_pipe
<<
1275 " from request " << old_request
<< " to " << new_request
);
1278 // update the current working ClientHttpRequest fields
1280 http
->uri
= SBufToCstring(new_request
->effectiveRequestUri());
1281 HTTPMSGUNLOCK(old_request
);
1282 http
->request
= new_request
;
1283 HTTPMSGLOCK(http
->request
);
1285 debugs(85, DBG_CRITICAL
, "ERROR: URL-rewrite produces invalid request: " <<
1286 old_request
->method
<< " " << urlNote
<< " " << old_request
->http_ver
);
1294 /* FIXME PIPELINE: This is innacurate during pipelining */
1296 if (http
->getConn() != NULL
&& Comm::IsConnOpen(http
->getConn()->clientConnection
))
1297 fd_note(http
->getConn()->clientConnection
->fd
, http
->uri
);
1305 * This method handles the different replies from StoreID helper.
1308 ClientRequestContext::clientStoreIdDone(const Helper::Reply
&reply
)
1310 HttpRequest
*old_request
= http
->request
;
1311 debugs(85, 5, "'" << http
->uri
<< "' result=" << reply
);
1312 assert(store_id_state
== REDIRECT_PENDING
);
1313 store_id_state
= REDIRECT_DONE
;
1315 // Put helper response Notes into the transaction state record (ALE) eventually
1316 // do it early to ensure that no matter what the outcome the notes are present.
1318 http
->al
->syncNotes(old_request
);
1320 UpdateRequestNotes(http
->getConn(), *old_request
, reply
.notes
);
1322 switch (reply
.result
) {
1323 case Helper::Unknown
:
1325 // Handler in redirect.cc should have already mapped Unknown
1326 // IF it contained valid entry for the old helper protocol
1327 debugs(85, DBG_IMPORTANT
, "ERROR: storeID helper returned invalid result code. Wrong helper? " << reply
);
1330 case Helper::TimedOut
:
1331 // Timeouts for storeID are not implemented
1332 case Helper::BrokenHelper
:
1333 debugs(85, DBG_IMPORTANT
, "ERROR: storeID helper: " << reply
);
1337 // no change to be done.
1340 case Helper::Okay
: {
1341 const char *urlNote
= reply
.notes
.findFirst("store-id");
1343 // prevent broken helpers causing too much damage. If old URL == new URL skip the re-write.
1344 if (urlNote
!= NULL
&& strcmp(urlNote
, http
->uri
) ) {
1345 // Debug section required for some very specific cases.
1346 debugs(85, 9, "Setting storeID with: " << urlNote
);
1347 http
->request
->store_id
= urlNote
;
1348 http
->store_id
= urlNote
;
1357 /** Test cache allow/deny configuration
1358 * Sets flags.cachable=1 if caching is not denied.
1361 ClientRequestContext::checkNoCache()
1363 if (Config
.accessList
.noCache
) {
1364 acl_checklist
= clientAclChecklistCreate(Config
.accessList
.noCache
, http
);
1365 acl_checklist
->nonBlockingCheck(checkNoCacheDoneWrapper
, this);
1367 /* unless otherwise specified, we try to cache. */
1368 checkNoCacheDone(ACCESS_ALLOWED
);
1373 checkNoCacheDoneWrapper(allow_t answer
, void *data
)
1375 ClientRequestContext
*calloutContext
= (ClientRequestContext
*) data
;
1377 if (!calloutContext
->httpStateIsValid())
1380 calloutContext
->checkNoCacheDone(answer
);
1384 ClientRequestContext::checkNoCacheDone(const allow_t
&answer
)
1386 acl_checklist
= NULL
;
1387 if (answer
.denied()) {
1388 http
->request
->flags
.noCache
= true; // dont read reply from cache
1389 http
->request
->flags
.cachable
= false; // dont store reply into cache
1396 ClientRequestContext::sslBumpAccessCheck()
1398 if (!http
->getConn()) {
1399 http
->al
->ssl
.bumpMode
= Ssl::bumpEnd
; // SslBump does not apply; log -
1403 const Ssl::BumpMode bumpMode
= http
->getConn()->sslBumpMode
;
1404 if (http
->request
->flags
.forceTunnel
) {
1405 debugs(85, 5, "not needed; already decided to tunnel " << http
->getConn());
1406 if (bumpMode
!= Ssl::bumpEnd
)
1407 http
->al
->ssl
.bumpMode
= bumpMode
; // inherited from bumped connection
1411 // If SSL connection tunneling or bumping decision has been made, obey it.
1412 if (bumpMode
!= Ssl::bumpEnd
) {
1413 debugs(85, 5, HERE
<< "SslBump already decided (" << bumpMode
<<
1414 "), " << "ignoring ssl_bump for " << http
->getConn());
1416 // We need the following "if" for transparently bumped TLS connection,
1417 // because in this case we are running ssl_bump access list before
1418 // the doCallouts runs. It can be removed after the bug #4340 fixed.
1419 // We do not want to proceed to bumping steps:
1420 // - if the TLS connection with the client is already established
1421 // because we are accepting normal HTTP requests on TLS port,
1422 // or because of the client-first bumping mode
1423 // - When the bumping is already started
1424 if (!http
->getConn()->switchedToHttps() &&
1425 !http
->getConn()->serverBump())
1426 http
->sslBumpNeed(bumpMode
); // for processRequest() to bump if needed and not already bumped
1427 http
->al
->ssl
.bumpMode
= bumpMode
; // inherited from bumped connection
1431 // If we have not decided yet, decide whether to bump now.
1433 // Bumping here can only start with a CONNECT request on a bumping port
1434 // (bumping of intercepted SSL conns is decided before we get 1st request).
1435 // We also do not bump redirected CONNECT requests.
1436 if (http
->request
->method
!= Http::METHOD_CONNECT
|| http
->redirect
.status
||
1437 !Config
.accessList
.ssl_bump
||
1438 !http
->getConn()->port
->flags
.tunnelSslBumping
) {
1439 http
->al
->ssl
.bumpMode
= Ssl::bumpEnd
; // SslBump does not apply; log -
1440 debugs(85, 5, HERE
<< "cannot SslBump this request");
1444 // Do not bump during authentication: clients would not proxy-authenticate
1445 // if we delay a 407 response and respond with 200 OK to CONNECT.
1446 if (error
&& error
->httpStatus
== Http::scProxyAuthenticationRequired
) {
1447 http
->al
->ssl
.bumpMode
= Ssl::bumpEnd
; // SslBump does not apply; log -
1448 debugs(85, 5, HERE
<< "no SslBump during proxy authentication");
1453 debugs(85, 5, "SslBump applies. Force bump action on error " << errorTypeName(error
->type
));
1454 http
->sslBumpNeed(Ssl::bumpBump
);
1455 http
->al
->ssl
.bumpMode
= Ssl::bumpBump
;
1459 debugs(85, 5, HERE
<< "SslBump possible, checking ACL");
1461 ACLFilledChecklist
*aclChecklist
= clientAclChecklistCreate(Config
.accessList
.ssl_bump
, http
);
1462 aclChecklist
->nonBlockingCheck(sslBumpAccessCheckDoneWrapper
, this);
1467 * A wrapper function to use the ClientRequestContext::sslBumpAccessCheckDone method
1468 * as ACLFilledChecklist callback
1471 sslBumpAccessCheckDoneWrapper(allow_t answer
, void *data
)
1473 ClientRequestContext
*calloutContext
= static_cast<ClientRequestContext
*>(data
);
1475 if (!calloutContext
->httpStateIsValid())
1477 calloutContext
->sslBumpAccessCheckDone(answer
);
1481 ClientRequestContext::sslBumpAccessCheckDone(const allow_t
&answer
)
1483 if (!httpStateIsValid())
1486 const Ssl::BumpMode bumpMode
= answer
.allowed() ?
1487 static_cast<Ssl::BumpMode
>(answer
.kind
) : Ssl::bumpSplice
;
1488 http
->sslBumpNeed(bumpMode
); // for processRequest() to bump if needed
1489 http
->al
->ssl
.bumpMode
= bumpMode
; // for logging
1491 if (bumpMode
== Ssl::bumpTerminate
) {
1492 const Comm::ConnectionPointer clientConn
= http
->getConn() ? http
->getConn()->clientConnection
: nullptr;
1493 if (Comm::IsConnOpen(clientConn
)) {
1494 debugs(85, 3, "closing after Ssl::bumpTerminate ");
1495 clientConn
->close();
1505 * Identify requests that do not go through the store and client side stream
1506 * and forward them to the appropriate location. All other requests, request
1510 ClientHttpRequest::processRequest()
1512 debugs(85, 4, request
->method
<< ' ' << uri
);
1514 const bool untouchedConnect
= request
->method
== Http::METHOD_CONNECT
&& !redirect
.status
;
1517 if (untouchedConnect
&& sslBumpNeeded()) {
1518 assert(!request
->flags
.forceTunnel
);
1524 if (untouchedConnect
|| request
->flags
.forceTunnel
) {
1525 getConn()->stopReading(); // tunnels read for themselves
1534 ClientHttpRequest::httpStart()
1536 PROF_start(httpStart
);
1537 logType
= LOG_TAG_NONE
;
1538 debugs(85, 4, logType
.c_str() << " for '" << uri
<< "'");
1540 /* no one should have touched this */
1541 assert(out
.offset
== 0);
1542 /* Use the Stream Luke */
1543 clientStreamNode
*node
= (clientStreamNode
*)client_stream
.tail
->data
;
1544 clientStreamRead(node
, this, node
->readBuffer
);
1545 PROF_stop(httpStart
);
1551 ClientHttpRequest::sslBumpNeed(Ssl::BumpMode mode
)
1553 debugs(83, 3, HERE
<< "sslBump required: "<< Ssl::bumpMode(mode
));
1554 sslBumpNeed_
= mode
;
1557 // called when comm_write has completed
1559 SslBumpEstablish(const Comm::ConnectionPointer
&, char *, size_t, Comm::Flag errflag
, int, void *data
)
1561 ClientHttpRequest
*r
= static_cast<ClientHttpRequest
*>(data
);
1562 debugs(85, 5, HERE
<< "responded to CONNECT: " << r
<< " ? " << errflag
);
1564 assert(r
&& cbdataReferenceValid(r
));
1565 r
->sslBumpEstablish(errflag
);
1569 ClientHttpRequest::sslBumpEstablish(Comm::Flag errflag
)
1571 // Bail out quickly on Comm::ERR_CLOSING - close handlers will tidy up
1572 if (errflag
== Comm::ERR_CLOSING
)
1576 debugs(85, 3, HERE
<< "CONNECT response failure in SslBump: " << errflag
);
1577 getConn()->clientConnection
->close();
1581 // We lack HttpReply which logRequest() uses to log the status code.
1582 // TODO: Use HttpReply instead of the "200 Connection established" string.
1583 al
->http
.code
= 200;
1586 // Preserve authentication info for the ssl-bumped request
1587 if (request
->auth_user_request
!= NULL
)
1588 getConn()->setAuth(request
->auth_user_request
, "SSL-bumped CONNECT");
1591 assert(sslBumpNeeded());
1592 getConn()->switchToHttps(request
, sslBumpNeed_
);
1596 ClientHttpRequest::sslBumpStart()
1598 debugs(85, 5, HERE
<< "Confirming " << Ssl::bumpMode(sslBumpNeed_
) <<
1599 "-bumped CONNECT tunnel on FD " << getConn()->clientConnection
);
1600 getConn()->sslBumpMode
= sslBumpNeed_
;
1602 AsyncCall::Pointer bumpCall
= commCbCall(85, 5, "ClientSocketContext::sslBumpEstablish",
1603 CommIoCbPtrFun(&SslBumpEstablish
, this));
1605 if (request
->flags
.interceptTproxy
|| request
->flags
.intercepted
) {
1606 CommIoCbParams
¶ms
= GetCommParams
<CommIoCbParams
>(bumpCall
);
1607 params
.flag
= Comm::OK
;
1608 params
.conn
= getConn()->clientConnection
;
1609 ScheduleCallHere(bumpCall
);
1613 // send an HTTP 200 response to kick client SSL negotiation
1614 // TODO: Unify with tunnel.cc and add a Server(?) header
1615 static const char *const conn_established
= "HTTP/1.1 200 Connection established\r\n\r\n";
1616 Comm::Write(getConn()->clientConnection
, conn_established
, strlen(conn_established
), bumpCall
, NULL
);
1622 ClientHttpRequest::gotEnough() const
1624 /** TODO: should be querying the stream. */
1625 int64_t contentLength
=
1626 memObject()->getReply()->bodySize(request
->method
);
1627 assert(contentLength
>= 0);
1629 if (out
.offset
< contentLength
)
1636 ClientHttpRequest::storeEntry(StoreEntry
*newEntry
)
1642 ClientHttpRequest::loggingEntry(StoreEntry
*newEntry
)
1645 loggingEntry_
->unlock("ClientHttpRequest::loggingEntry");
1647 loggingEntry_
= newEntry
;
1650 loggingEntry_
->lock("ClientHttpRequest::loggingEntry");
1654 * doCallouts() - This function controls the order of "callout"
1655 * executions, including non-blocking access control checks, the
1656 * redirector, and ICAP. Previously, these callouts were chained
1657 * together such that "clientAccessCheckDone()" would call
1658 * "clientRedirectStart()" and so on.
1660 * The ClientRequestContext (aka calloutContext) class holds certain
1661 * state data for the callout/callback operations. Previously
1662 * ClientHttpRequest would sort of hand off control to ClientRequestContext
1663 * for a short time. ClientRequestContext would then delete itself
1664 * and pass control back to ClientHttpRequest when all callouts
1667 * This caused some problems for ICAP because we want to make the
1668 * ICAP callout after checking ACLs, but before checking the no_cache
1669 * list. We can't stuff the ICAP state into the ClientRequestContext
1670 * class because we still need the ICAP state after ClientRequestContext
1673 * Note that ClientRequestContext is created before the first call
1676 * If one of the callouts notices that ClientHttpRequest is no
1677 * longer valid, it should call cbdataReferenceDone() so that
1678 * ClientHttpRequest's reference count goes to zero and it will get
1679 * deleted. ClientHttpRequest will then delete ClientRequestContext.
1681 * Note that we set the _done flags here before actually starting
1682 * the callout. This is strictly for convenience.
1685 tos_t
aclMapTOS (acl_tos
* head
, ACLChecklist
* ch
);
1686 nfmark_t
aclMapNfmark (acl_nfmark
* head
, ACLChecklist
* ch
);
1689 ClientHttpRequest::doCallouts()
1691 assert(calloutContext
);
1693 auto &ale
= calloutContext
->http
->al
;
1694 /*Save the original request for logging purposes*/
1695 if (!ale
->request
) {
1696 ale
->request
= request
;
1697 HTTPMSGLOCK(ale
->request
);
1699 // Make the previously set client connection ID available as annotation.
1700 if (ConnStateData
*csd
= calloutContext
->http
->getConn()) {
1701 if (!csd
->notes()->empty())
1702 calloutContext
->http
->request
->notes()->appendNewOnly(csd
->notes().getRaw());
1704 ale
->syncNotes(calloutContext
->http
->request
);
1707 if (!calloutContext
->error
) {
1708 // CVE-2009-0801: verify the Host: header is consistent with other known details.
1709 if (!calloutContext
->host_header_verify_done
) {
1710 debugs(83, 3, HERE
<< "Doing calloutContext->hostHeaderVerify()");
1711 calloutContext
->host_header_verify_done
= true;
1712 calloutContext
->hostHeaderVerify();
1716 if (!calloutContext
->http_access_done
) {
1717 debugs(83, 3, HERE
<< "Doing calloutContext->clientAccessCheck()");
1718 calloutContext
->http_access_done
= true;
1719 calloutContext
->clientAccessCheck();
1724 if (!calloutContext
->adaptation_acl_check_done
) {
1725 calloutContext
->adaptation_acl_check_done
= true;
1726 if (Adaptation::AccessCheck::Start(
1727 Adaptation::methodReqmod
, Adaptation::pointPreCache
,
1728 request
, NULL
, calloutContext
->http
->al
, this))
1729 return; // will call callback
1733 if (!calloutContext
->redirect_done
) {
1734 calloutContext
->redirect_done
= true;
1736 if (Config
.Program
.redirect
) {
1737 debugs(83, 3, HERE
<< "Doing calloutContext->clientRedirectStart()");
1738 calloutContext
->redirect_state
= REDIRECT_PENDING
;
1739 calloutContext
->clientRedirectStart();
1744 if (!calloutContext
->adapted_http_access_done
) {
1745 debugs(83, 3, HERE
<< "Doing calloutContext->clientAccessCheck2()");
1746 calloutContext
->adapted_http_access_done
= true;
1747 calloutContext
->clientAccessCheck2();
1751 if (!calloutContext
->store_id_done
) {
1752 calloutContext
->store_id_done
= true;
1754 if (Config
.Program
.store_id
) {
1755 debugs(83, 3,"Doing calloutContext->clientStoreIdStart()");
1756 calloutContext
->store_id_state
= REDIRECT_PENDING
;
1757 calloutContext
->clientStoreIdStart();
1762 if (!calloutContext
->interpreted_req_hdrs
) {
1763 debugs(83, 3, HERE
<< "Doing clientInterpretRequestHeaders()");
1764 calloutContext
->interpreted_req_hdrs
= 1;
1765 clientInterpretRequestHeaders(this);
1768 if (!calloutContext
->no_cache_done
) {
1769 calloutContext
->no_cache_done
= true;
1771 if (Config
.accessList
.noCache
&& request
->flags
.cachable
) {
1772 debugs(83, 3, HERE
<< "Doing calloutContext->checkNoCache()");
1773 calloutContext
->checkNoCache();
1777 } // if !calloutContext->error
1779 if (!calloutContext
->tosToClientDone
) {
1780 calloutContext
->tosToClientDone
= true;
1781 if (getConn() != NULL
&& Comm::IsConnOpen(getConn()->clientConnection
)) {
1782 ACLFilledChecklist
ch(NULL
, request
, NULL
);
1783 ch
.src_addr
= request
->client_addr
;
1784 ch
.my_addr
= request
->my_addr
;
1785 tos_t tos
= aclMapTOS(Ip::Qos::TheConfig
.tosToClient
, &ch
);
1787 Ip::Qos::setSockTos(getConn()->clientConnection
, tos
);
1791 if (!calloutContext
->nfmarkToClientDone
) {
1792 calloutContext
->nfmarkToClientDone
= true;
1793 if (getConn() != NULL
&& Comm::IsConnOpen(getConn()->clientConnection
)) {
1794 ACLFilledChecklist
ch(NULL
, request
, NULL
);
1795 ch
.src_addr
= request
->client_addr
;
1796 ch
.my_addr
= request
->my_addr
;
1797 nfmark_t mark
= aclMapNfmark(Ip::Qos::TheConfig
.nfmarkToClient
, &ch
);
1799 Ip::Qos::setSockNfmark(getConn()->clientConnection
, mark
);
1804 // Even with calloutContext->error, we call sslBumpAccessCheck() to decide
1805 // whether SslBump applies to this transaction. If it applies, we will
1806 // attempt to bump the client to serve the error.
1807 if (!calloutContext
->sslBumpCheckDone
) {
1808 calloutContext
->sslBumpCheckDone
= true;
1809 if (calloutContext
->sslBumpAccessCheck())
1811 /* else no ssl bump required*/
1815 if (calloutContext
->error
) {
1816 // XXX: prformance regression. c_str() reallocates
1817 SBuf
storeUriBuf(request
->storeId());
1818 const char *storeUri
= storeUriBuf
.c_str();
1819 StoreEntry
*e
= storeCreateEntry(storeUri
, storeUri
, request
->flags
, request
->method
);
1821 if (sslBumpNeeded()) {
1822 // We have to serve an error, so bump the client first.
1823 sslBumpNeed(Ssl::bumpClientFirst
);
1824 // set final error but delay sending until we bump
1825 Ssl::ServerBump
*srvBump
= new Ssl::ServerBump(request
, e
, Ssl::bumpClientFirst
);
1826 errorAppendEntry(e
, calloutContext
->error
);
1827 calloutContext
->error
= NULL
;
1828 getConn()->setServerBump(srvBump
);
1829 e
->unlock("ClientHttpRequest::doCallouts+sslBumpNeeded");
1833 // send the error to the client now
1834 clientStreamNode
*node
= (clientStreamNode
*)client_stream
.tail
->prev
->data
;
1835 clientReplyContext
*repContext
= dynamic_cast<clientReplyContext
*>(node
->data
.getRaw());
1836 assert (repContext
);
1837 repContext
->setReplyToStoreEntry(e
, "immediate SslBump error");
1838 errorAppendEntry(e
, calloutContext
->error
);
1839 calloutContext
->error
= NULL
;
1840 if (calloutContext
->readNextRequest
&& getConn())
1841 getConn()->flags
.readMore
= true; // resume any pipeline reads.
1842 node
= (clientStreamNode
*)client_stream
.tail
->data
;
1843 clientStreamRead(node
, this, node
->readBuffer
);
1844 e
->unlock("ClientHttpRequest::doCallouts-sslBumpNeeded");
1849 cbdataReferenceDone(calloutContext
->http
);
1850 delete calloutContext
;
1851 calloutContext
= NULL
;
1854 headersLog(0, 1, request
->method
, request
);
1857 debugs(83, 3, HERE
<< "calling processRequest()");
1861 Adaptation::Icap::History::Pointer ih
= request
->icapHistory();
1863 ih
->logType
= logType
;
1868 /// Initiate an asynchronous adaptation transaction which will call us back.
1870 ClientHttpRequest::startAdaptation(const Adaptation::ServiceGroupPointer
&g
)
1872 debugs(85, 3, HERE
<< "adaptation needed for " << this);
1873 assert(!virginHeadSource
);
1874 assert(!adaptedBodySource
);
1875 virginHeadSource
= initiateAdaptation(
1876 new Adaptation::Iterator(request
, NULL
, al
, g
));
1878 // we could try to guess whether we can bypass this adaptation
1879 // initiation failure, but it should not really happen
1880 Must(initiated(virginHeadSource
));
1884 ClientHttpRequest::noteAdaptationAnswer(const Adaptation::Answer
&answer
)
1886 assert(cbdataReferenceValid(this)); // indicates bug
1887 clearAdaptation(virginHeadSource
);
1888 assert(!adaptedBodySource
);
1890 switch (answer
.kind
) {
1891 case Adaptation::Answer::akForward
:
1892 handleAdaptedHeader(const_cast<Http::Message
*>(answer
.message
.getRaw()));
1895 case Adaptation::Answer::akBlock
:
1896 handleAdaptationBlock(answer
);
1899 case Adaptation::Answer::akError
:
1900 handleAdaptationFailure(ERR_DETAIL_CLT_REQMOD_ABORT
, !answer
.final
);
1906 ClientHttpRequest::handleAdaptedHeader(Http::Message
*msg
)
1910 if (HttpRequest
*new_req
= dynamic_cast<HttpRequest
*>(msg
)) {
1912 * Replace the old request with the new request.
1914 HTTPMSGUNLOCK(request
);
1916 HTTPMSGLOCK(request
);
1918 // update the new message to flag whether URL re-writing was done on it
1919 if (request
->effectiveRequestUri().cmp(uri
) != 0)
1920 request
->flags
.redirected
= 1;
1923 * Store the new URI for logging
1926 uri
= SBufToCstring(request
->effectiveRequestUri());
1927 setLogUri(this, urlCanonicalClean(request
));
1928 assert(request
->method
.id());
1929 } else if (HttpReply
*new_rep
= dynamic_cast<HttpReply
*>(msg
)) {
1930 debugs(85,3,HERE
<< "REQMOD reply is HTTP reply");
1932 // subscribe to receive reply body
1933 if (new_rep
->body_pipe
!= NULL
) {
1934 adaptedBodySource
= new_rep
->body_pipe
;
1935 int consumer_ok
= adaptedBodySource
->setConsumerIfNotLate(this);
1936 assert(consumer_ok
);
1939 clientStreamNode
*node
= (clientStreamNode
*)client_stream
.tail
->prev
->data
;
1940 clientReplyContext
*repContext
= dynamic_cast<clientReplyContext
*>(node
->data
.getRaw());
1942 repContext
->createStoreEntry(request
->method
, request
->flags
);
1944 EBIT_CLR(storeEntry()->flags
, ENTRY_FWD_HDR_WAIT
);
1945 request_satisfaction_mode
= true;
1946 request_satisfaction_offset
= 0;
1947 storeEntry()->replaceHttpReply(new_rep
);
1948 storeEntry()->timestampsSet();
1950 if (!adaptedBodySource
) // no body
1951 storeEntry()->complete();
1952 clientGetMoreData(node
, this);
1955 // we are done with getting headers (but may be receiving body)
1956 clearAdaptation(virginHeadSource
);
1958 if (!request_satisfaction_mode
)
1963 ClientHttpRequest::handleAdaptationBlock(const Adaptation::Answer
&answer
)
1965 request
->detailError(ERR_ACCESS_DENIED
, ERR_DETAIL_REQMOD_BLOCK
);
1966 AclMatchedName
= answer
.ruleId
.termedBuf();
1967 assert(calloutContext
);
1968 calloutContext
->clientAccessCheckDone(ACCESS_DENIED
);
1969 AclMatchedName
= NULL
;
1973 ClientHttpRequest::resumeBodyStorage()
1975 if (!adaptedBodySource
)
1978 noteMoreBodyDataAvailable(adaptedBodySource
);
1982 ClientHttpRequest::noteMoreBodyDataAvailable(BodyPipe::Pointer
)
1984 assert(request_satisfaction_mode
);
1985 assert(adaptedBodySource
!= NULL
);
1987 if (size_t contentSize
= adaptedBodySource
->buf().contentSize()) {
1988 const size_t spaceAvailable
= storeEntry()->bytesWanted(Range
<size_t>(0,contentSize
));
1990 if (spaceAvailable
< contentSize
) {
1991 // No or partial body data consuming
1992 typedef NullaryMemFunT
<ClientHttpRequest
> Dialer
;
1993 AsyncCall::Pointer call
= asyncCall(93, 5, "ClientHttpRequest::resumeBodyStorage",
1994 Dialer(this, &ClientHttpRequest::resumeBodyStorage
));
1995 storeEntry()->deferProducer(call
);
1998 if (!spaceAvailable
)
2001 if (spaceAvailable
< contentSize
)
2002 contentSize
= spaceAvailable
;
2004 BodyPipeCheckout
bpc(*adaptedBodySource
);
2005 const StoreIOBuffer
ioBuf(&bpc
.buf
, request_satisfaction_offset
, contentSize
);
2006 storeEntry()->write(ioBuf
);
2007 // assume StoreEntry::write() writes the entire ioBuf
2008 request_satisfaction_offset
+= ioBuf
.length
;
2009 bpc
.buf
.consume(contentSize
);
2013 if (adaptedBodySource
->exhausted())
2014 endRequestSatisfaction();
2015 // else wait for more body data
2019 ClientHttpRequest::noteBodyProductionEnded(BodyPipe::Pointer
)
2021 assert(!virginHeadSource
);
2022 // should we end request satisfaction now?
2023 if (adaptedBodySource
!= NULL
&& adaptedBodySource
->exhausted())
2024 endRequestSatisfaction();
2028 ClientHttpRequest::endRequestSatisfaction()
2030 debugs(85,4, HERE
<< this << " ends request satisfaction");
2031 assert(request_satisfaction_mode
);
2032 stopConsumingFrom(adaptedBodySource
);
2034 // TODO: anything else needed to end store entry formation correctly?
2035 storeEntry()->complete();
2039 ClientHttpRequest::noteBodyProducerAborted(BodyPipe::Pointer
)
2041 assert(!virginHeadSource
);
2042 stopConsumingFrom(adaptedBodySource
);
2044 debugs(85,3, HERE
<< "REQMOD body production failed");
2045 if (request_satisfaction_mode
) { // too late to recover or serve an error
2046 request
->detailError(ERR_ICAP_FAILURE
, ERR_DETAIL_CLT_REQMOD_RESP_BODY
);
2047 const Comm::ConnectionPointer c
= getConn()->clientConnection
;
2048 Must(Comm::IsConnOpen(c
));
2049 c
->close(); // drastic, but we may be writing a response already
2051 handleAdaptationFailure(ERR_DETAIL_CLT_REQMOD_REQ_BODY
);
2056 ClientHttpRequest::handleAdaptationFailure(int errDetail
, bool bypassable
)
2058 debugs(85,3, HERE
<< "handleAdaptationFailure(" << bypassable
<< ")");
2060 const bool usedStore
= storeEntry() && !storeEntry()->isEmpty();
2061 const bool usedPipe
= request
->body_pipe
!= NULL
&&
2062 request
->body_pipe
->consumedSize() > 0;
2064 if (bypassable
&& !usedStore
&& !usedPipe
) {
2065 debugs(85,3, HERE
<< "ICAP REQMOD callout failed, bypassing: " << calloutContext
);
2071 debugs(85,3, HERE
<< "ICAP REQMOD callout failed, responding with error");
2073 clientStreamNode
*node
= (clientStreamNode
*)client_stream
.tail
->prev
->data
;
2074 clientReplyContext
*repContext
= dynamic_cast<clientReplyContext
*>(node
->data
.getRaw());
2077 calloutsError(ERR_ICAP_FAILURE
, errDetail
);
2084 ClientHttpRequest::callException(const std::exception
&ex
)
2086 if (const auto clientConn
= getConn() ? getConn()->clientConnection
: nullptr) {
2087 if (Comm::IsConnOpen(clientConn
)) {
2088 debugs(85, 3, "closing after exception: " << ex
.what());
2089 clientConn
->close(); // initiate orderly top-to-bottom cleanup
2093 debugs(85, DBG_IMPORTANT
, "ClientHttpRequest exception without connection. Ignoring " << ex
.what());
2094 // XXX: Normally, we mustStop() but we cannot do that here because it is
2095 // likely to leave Http::Stream and ConnStateData with a dangling http
2096 // pointer. See r13480 or XXX in Http::Stream class description.
2100 // XXX: modify and use with ClientRequestContext::clientAccessCheckDone too.
2102 ClientHttpRequest::calloutsError(const err_type error
, const int errDetail
)
2104 // The original author of the code also wanted to pass an errno to
2105 // setReplyToError, but it seems unlikely that the errno reflects the
2106 // true cause of the error at this point, so I did not pass it.
2107 if (calloutContext
) {
2110 ConnStateData
* c
= getConn();
2111 calloutContext
->error
= clientBuildError(error
, Http::scInternalServerError
,
2113 c
!= NULL
? c
->clientConnection
->remote
: noAddr
,
2117 calloutContext
->error
->auth_user_request
=
2118 c
!= NULL
&& c
->getAuth() != NULL
? c
->getAuth() : request
->auth_user_request
;
2120 calloutContext
->error
->detailError(errDetail
);
2121 calloutContext
->readNextRequest
= true;
2123 c
->expectNoForwarding();
2125 //else if(calloutContext == NULL) is it possible?