]> git.ipfire.org Git - thirdparty/squid.git/blame - src/client_side_request.cc
unlinkdClose() should be called after (not before) Store::Root().sync()
[thirdparty/squid.git] / src / client_side_request.cc
CommitLineData
edce4d98 1
2/*
c99de607 3 * $Id: client_side_request.cc,v 1.77 2006/10/31 23:30:57 wessels Exp $
69660be0 4 *
ae45c4de 5 * DEBUG: section 85 Client-side Request Routines
6 * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
69660be0 7 *
edce4d98 8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
0a9297f6 10 *
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
33 *
edce4d98 34 */
35
36
69660be0 37/*
38 * General logic of request processing:
39 *
40 * We run a series of tests to determine if access will be permitted, and to do
41 * any redirection. Then we call into the result clientStream to retrieve data.
42 * From that point on it's up to reply management.
edce4d98 43 */
44
45#include "squid.h"
c8be6d7b 46#include "clientStream.h"
47#include "client_side_request.h"
f5691f9c 48#include "AuthUserRequest.h"
528b2c61 49#include "HttpRequest.h"
8000a965 50#include "ACLChecklist.h"
51#include "ACL.h"
a46d2c0e 52#include "client_side.h"
0655fa4d 53#include "client_side_reply.h"
54#include "Store.h"
55#include "HttpReply.h"
86a2f789 56#include "MemObject.h"
de31d06f 57#include "ClientRequestContext.h"
985c86bc 58#include "SquidTime.h"
d295d770 59#include "wordlist.h"
de31d06f 60
61#if ICAP_CLIENT
62#include "ICAP/ICAPClientReqmodPrecache.h"
63#include "ICAP/ICAPElements.h"
64#include "ICAP/ICAPConfig.h"
65static void icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data);
ab7ac359 66extern ICAPConfig TheICAPConfig;
de31d06f 67#endif
edce4d98 68
69#if LINGERING_CLOSE
70#define comm_close comm_lingering_close
71#endif
72
73static const char *const crlf = "\r\n";
74
8e2745f4 75CBDATA_CLASS_INIT(ClientRequestContext);
76
77void *
78ClientRequestContext::operator new (size_t size)
79{
80 assert (size == sizeof(ClientRequestContext));
81 CBDATA_INIT_TYPE(ClientRequestContext);
82 ClientRequestContext *result = cbdataAlloc(ClientRequestContext);
aa625860 83 return result;
8e2745f4 84}
62e76326 85
8e2745f4 86void
87ClientRequestContext::operator delete (void *address)
88{
89 ClientRequestContext *t = static_cast<ClientRequestContext *>(address);
aa625860 90 cbdataFree(t);
8e2745f4 91}
92
edce4d98 93/* Local functions */
edce4d98 94/* other */
de31d06f 95static void clientAccessCheckDoneWrapper(int, void *);
59a1efb2 96static int clientHierarchical(ClientHttpRequest * http);
97static void clientInterpretRequestHeaders(ClientHttpRequest * http);
de31d06f 98static RH clientRedirectDoneWrapper;
99static PF checkNoCacheDoneWrapper;
e6ccf245 100extern "C" CSR clientGetMoreData;
101extern "C" CSS clientReplyStatus;
102extern "C" CSD clientReplyDetach;
528b2c61 103static void checkFailureRatio(err_type, hier_code);
edce4d98 104
8e2745f4 105ClientRequestContext::~ClientRequestContext()
106{
de31d06f 107 /*
a546b04b 108 * Release our "lock" on our parent, ClientHttpRequest, if we
109 * still have one
de31d06f 110 */
a546b04b 111
112 if (http)
113 cbdataReferenceDone(http);
62e76326 114
501b58f9 115 if (acl_checklist) {
116 if (acl_checklist->asyncInProgress()) {
117 acl_checklist->markDeleteWhenDone();
118 } else {
119 delete acl_checklist;
120 }
121 }
6ec67de9 122
123 debugs(85,3, HERE << this << " ClientHttpRequest destructed");
8e2745f4 124}
125
4e2eb5c3 126ClientRequestContext::ClientRequestContext(ClientHttpRequest *anHttp) : http(cbdataReference(anHttp)), acl_checklist (NULL), redirect_state (REDIRECT_NONE)
edce4d98 127{
57abaac0 128 http_access_done = false;
129 redirect_done = false;
130 no_cache_done = false;
131 interpreted_req_hdrs = false;
0b86805b 132 debugs(85,3, HERE << this << " ClientRequestContext constructed");
edce4d98 133}
134
528b2c61 135CBDATA_CLASS_INIT(ClientHttpRequest);
8e2745f4 136
528b2c61 137void *
138ClientHttpRequest::operator new (size_t size)
139{
140 assert (size == sizeof (ClientHttpRequest));
141 CBDATA_INIT_TYPE(ClientHttpRequest);
142 ClientHttpRequest *result = cbdataAlloc(ClientHttpRequest);
aa625860 143 return result;
528b2c61 144}
145
62e76326 146void
528b2c61 147ClientHttpRequest::operator delete (void *address)
148{
aa625860 149 ClientHttpRequest *t = static_cast<ClientHttpRequest *>(address);
150 cbdataFree(t);
528b2c61 151}
152
a0355e95 153ClientHttpRequest::ClientHttpRequest(ConnStateData::Pointer aConn) : loggingEntry_(NULL)
528b2c61 154{
528b2c61 155 start = current_time;
a0355e95 156 setConn(aConn);
157 dlinkAdd(this, &active, &ClientActiveRequests);
b044675d 158#if ICAP_CLIENT
159
160 request_satisfaction_mode = false;
161#endif
528b2c61 162}
163
0655fa4d 164/*
165 * returns true if client specified that the object must come from the cache
166 * without contacting origin server
167 */
168bool
169ClientHttpRequest::onlyIfCached()const
170{
171 assert(request);
172 return request->cache_control &&
173 EBIT_TEST(request->cache_control->mask, CC_ONLY_IF_CACHED);
174}
175
528b2c61 176/*
177 * This function is designed to serve a fairly specific purpose.
178 * Occasionally our vBNS-connected caches can talk to each other, but not
179 * the rest of the world. Here we try to detect frequent failures which
180 * make the cache unusable (e.g. DNS lookup and connect() failures). If
181 * the failure:success ratio goes above 1.0 then we go into "hit only"
182 * mode where we only return UDP_HIT or UDP_MISS_NOFETCH. Neighbors
183 * will only fetch HITs from us if they are using the ICP protocol. We
184 * stay in this mode for 5 minutes.
185 *
186 * Duane W., Sept 16, 1996
187 */
188
189#define FAILURE_MODE_TIME 300
190
191static void
192checkFailureRatio(err_type etype, hier_code hcode)
193{
194 static double magic_factor = 100.0;
195 double n_good;
196 double n_bad;
62e76326 197
528b2c61 198 if (hcode == HIER_NONE)
62e76326 199 return;
200
528b2c61 201 n_good = magic_factor / (1.0 + request_failure_ratio);
62e76326 202
528b2c61 203 n_bad = magic_factor - n_good;
62e76326 204
528b2c61 205 switch (etype) {
62e76326 206
528b2c61 207 case ERR_DNS_FAIL:
62e76326 208
528b2c61 209 case ERR_CONNECT_FAIL:
62e76326 210
528b2c61 211 case ERR_READ_ERROR:
62e76326 212 n_bad++;
213 break;
214
528b2c61 215 default:
62e76326 216 n_good++;
528b2c61 217 }
62e76326 218
528b2c61 219 request_failure_ratio = n_bad / n_good;
62e76326 220
528b2c61 221 if (hit_only_mode_until > squid_curtime)
62e76326 222 return;
223
528b2c61 224 if (request_failure_ratio < 1.0)
62e76326 225 return;
226
528b2c61 227 debug(33, 0) ("Failure Ratio at %4.2f\n", request_failure_ratio);
62e76326 228
528b2c61 229 debug(33, 0) ("Going into hit-only-mode for %d minutes...\n",
62e76326 230 FAILURE_MODE_TIME / 60);
231
528b2c61 232 hit_only_mode_until = squid_curtime + FAILURE_MODE_TIME;
62e76326 233
528b2c61 234 request_failure_ratio = 0.8; /* reset to something less than 1.0 */
235}
236
237ClientHttpRequest::~ClientHttpRequest()
238{
239 debug(33, 3) ("httpRequestFree: %s\n", uri);
72bdee4c 240 PROF_start(httpRequestFree);
528b2c61 241 /* if body_connection !NULL, then ProcessBody has not
242 * found the end of the body yet
243 */
62e76326 244
3b299123 245 if (request && request->body_reader != NULL) {
0b86805b 246 request->body_reader = NULL; // refcounted, triggers abort if needed.
247 debugs(32, 3, HERE << "setting body_reader = NULL for request " << request);
21b92762 248 }
62e76326 249
528b2c61 250 /* the ICP check here was erroneous
251 * - storeReleaseRequest was always called if entry was valid
252 */
253 assert(logType < LOG_TYPE_MAX);
254 logRequest();
0976f8db 255 loggingEntry(NULL);
256
528b2c61 257 if (request)
62e76326 258 checkFailureRatio(request->errType, al.hier.code);
259
528b2c61 260 freeResources();
62e76326 261
de31d06f 262#if ICAP_CLIENT
4e2eb5c3 263 if (icap)
de31d06f 264 delete icap;
de31d06f 265#endif
266 if (calloutContext)
267 delete calloutContext;
268
528b2c61 269 /* moving to the next connection is handled by the context free */
270 dlinkDelete(&active, &ClientActiveRequests);
72bdee4c 271 PROF_stop(httpRequestFree);
528b2c61 272}
62e76326 273
edce4d98 274/* Create a request and kick it off */
69660be0 275/*
276 * TODO: Pass in the buffers to be used in the inital Read request, as they are
277 * determined by the user
edce4d98 278 */
279int /* returns nonzero on failure */
280clientBeginRequest(method_t method, char const *url, CSCB * streamcallback,
0655fa4d 281 CSD * streamdetach, ClientStreamData streamdata, HttpHeader const *header,
62e76326 282 char *tailbuf, size_t taillen)
edce4d98 283{
284 size_t url_sz;
450e0c10 285 HttpVersion http_ver (1, 0);
a0355e95 286 ClientHttpRequest *http = new ClientHttpRequest(NULL);
190154cf 287 HttpRequest *request;
528b2c61 288 StoreIOBuffer tempBuffer;
edce4d98 289 http->start = current_time;
290 /* this is only used to adjust the connection offset in client_side.c */
291 http->req_sz = 0;
c8be6d7b 292 tempBuffer.length = taillen;
293 tempBuffer.data = tailbuf;
edce4d98 294 /* client stream setup */
295 clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach,
0655fa4d 296 clientReplyStatus, new clientReplyContext(http), streamcallback,
62e76326 297 streamdetach, streamdata, tempBuffer);
edce4d98 298 /* make it visible in the 'current acctive requests list' */
edce4d98 299 /* Set flags */
a46d2c0e 300 /* internal requests only makes sense in an
301 * accelerator today. TODO: accept flags ? */
302 http->flags.accel = 1;
edce4d98 303 /* allow size for url rewriting */
304 url_sz = strlen(url) + Config.appendDomainLen + 5;
e6ccf245 305 http->uri = (char *)xcalloc(url_sz, 1);
edce4d98 306 strcpy(http->uri, url);
307
c21ad0f5 308 if ((request = HttpRequest::CreateFromUrlAndMethod(http->uri, method)) == NULL) {
62e76326 309 debug(85, 5) ("Invalid URL: %s\n", http->uri);
310 return -1;
edce4d98 311 }
62e76326 312
69660be0 313 /*
314 * now update the headers in request with our supplied headers. urLParse
315 * should return a blank header set, but we use Update to be sure of
316 * correctness.
edce4d98 317 */
318 if (header)
a9925b40 319 request->header.update(header, NULL);
62e76326 320
edce4d98 321 http->log_uri = xstrdup(urlCanonicalClean(request));
62e76326 322
edce4d98 323 /* http struct now ready */
324
69660be0 325 /*
326 * build new header list *? TODO
edce4d98 327 */
328 request->flags.accelerated = http->flags.accel;
62e76326 329
a46d2c0e 330 request->flags.internalclient = 1;
331
332 /* this is an internally created
333 * request, not subject to acceleration
334 * target overrides */
69660be0 335 /*
336 * FIXME? Do we want to detect and handle internal requests of internal
337 * objects ?
338 */
edce4d98 339
340 /* Internally created requests cannot have bodies today */
341 request->content_length = 0;
62e76326 342
edce4d98 343 request->client_addr = no_addr;
62e76326 344
edce4d98 345 request->my_addr = no_addr; /* undefined for internal requests */
62e76326 346
edce4d98 347 request->my_port = 0;
62e76326 348
edce4d98 349 request->http_ver = http_ver;
62e76326 350
6dd9f4bd 351 http->request = HTTPMSGLOCK(request);
edce4d98 352
353 /* optional - skip the access check ? */
de31d06f 354 http->calloutContext = new ClientRequestContext(http);
355
57abaac0 356 http->calloutContext->http_access_done = false;
de31d06f 357
57abaac0 358 http->calloutContext->redirect_done = true;
de31d06f 359
57abaac0 360 http->calloutContext->no_cache_done = true;
de31d06f 361
362 http->doCallouts();
62e76326 363
edce4d98 364 return 0;
365}
366
de31d06f 367bool
368ClientRequestContext::httpStateIsValid()
369{
370 ClientHttpRequest *http_ = http;
371
372 if (cbdataReferenceValid(http_))
373 return true;
374
375 http = NULL;
376
377 cbdataReferenceDone(http_);
378
379 return false;
380}
381
edce4d98 382/* This is the entry point for external users of the client_side routines */
383void
de31d06f 384ClientRequestContext::clientAccessCheck()
edce4d98 385{
de31d06f 386 acl_checklist =
62e76326 387 clientAclChecklistCreate(Config.accessList.http, http);
de31d06f 388 acl_checklist->nonBlockingCheck(clientAccessCheckDoneWrapper, this);
edce4d98 389}
390
391void
de31d06f 392clientAccessCheckDoneWrapper(int answer, void *data)
edce4d98 393{
de31d06f 394 ClientRequestContext *calloutContext = (ClientRequestContext *) data;
fbade053 395
de31d06f 396 if (!calloutContext->httpStateIsValid())
62e76326 397 return;
62e76326 398
de31d06f 399 calloutContext->clientAccessCheckDone(answer);
400}
401
402void
403ClientRequestContext::clientAccessCheckDone(int answer)
404{
405 acl_checklist = NULL;
edce4d98 406 err_type page_id;
407 http_status status;
edce4d98 408 debug(85, 2) ("The request %s %s is %s, because it matched '%s'\n",
62e76326 409 RequestMethodStr[http->request->method], http->uri,
410 answer == ACCESS_ALLOWED ? "ALLOWED" : "DENIED",
411 AclMatchedName ? AclMatchedName : "NO ACL's");
f5691f9c 412 char const *proxy_auth_msg = "<null>";
413
414 if (http->getConn().getRaw() != NULL && http->getConn()->auth_user_request != NULL)
415 proxy_auth_msg = http->getConn()->auth_user_request->denyMessage("<null>");
416 else if (http->request->auth_user_request != NULL)
417 proxy_auth_msg = http->request->auth_user_request->denyMessage("<null>");
62e76326 418
de31d06f 419 if (answer != ACCESS_ALLOWED) {
62e76326 420 /* Send an error */
62e76326 421 debug(85, 5) ("Access Denied: %s\n", http->uri);
422 debug(85, 5) ("AclMatchedName = %s\n",
423 AclMatchedName ? AclMatchedName : "<null>");
424 debug(85, 5) ("Proxy Auth Message = %s\n",
425 proxy_auth_msg ? proxy_auth_msg : "<null>");
426 /*
427 * NOTE: get page_id here, based on AclMatchedName because if
428 * USE_DELAY_POOLS is enabled, then AclMatchedName gets clobbered in
429 * the clientCreateStoreEntry() call just below. Pedro Ribeiro
430 * <pribeiro@isel.pt>
431 */
432 page_id = aclGetDenyInfoPage(&Config.denyInfoList, AclMatchedName);
433 http->logType = LOG_TCP_DENIED;
434
435 if (answer == ACCESS_REQ_PROXY_AUTH || aclIsProxyAuth(AclMatchedName)) {
436 if (!http->flags.accel) {
437 /* Proxy authorisation needed */
438 status = HTTP_PROXY_AUTHENTICATION_REQUIRED;
439 } else {
440 /* WWW authorisation needed */
441 status = HTTP_UNAUTHORIZED;
442 }
443
444 if (page_id == ERR_NONE)
445 page_id = ERR_CACHE_ACCESS_DENIED;
446 } else {
447 status = HTTP_FORBIDDEN;
448
449 if (page_id == ERR_NONE)
450 page_id = ERR_ACCESS_DENIED;
451 }
452
de31d06f 453 clientStreamNode *node = (clientStreamNode *)http->client_stream.tail->prev->data;
0655fa4d 454 clientReplyContext *repContext = dynamic_cast<clientReplyContext *>(node->data.getRaw());
455 assert (repContext);
456 repContext->setReplyToError(page_id, status,
457 http->request->method, NULL,
a2ac85d9 458 http->getConn().getRaw() != NULL ? &http->getConn()->peer.sin_addr : &no_addr, http->request,
459 NULL, http->getConn().getRaw() != NULL
98242069 460 && http->getConn()->auth_user_request ? http->getConn()->
0655fa4d 461 auth_user_request : http->request->auth_user_request);
62e76326 462 node = (clientStreamNode *)http->client_stream.tail->data;
463 clientStreamRead(node, http, node->readBuffer);
a546b04b 464 return;
edce4d98 465 }
de31d06f 466
467 /* ACCESS_ALLOWED continues here ... */
468 safe_free(http->uri);
469
470 http->uri = xstrdup(urlCanonical(http->request));
471
472 http->doCallouts();
473}
474
475#if ICAP_CLIENT
476void
477ClientRequestContext::icapAccessCheck()
478{
479 ICAPAccessCheck *icap_access_check;
480
e8fe1384 481 icap_access_check = new ICAPAccessCheck(ICAP::methodReqmod, ICAP::pointPreCache, http->request, NULL, icapAclCheckDoneWrapper, this);
482
483 if (icap_access_check != NULL) {
de31d06f 484 icap_access_check->check();
485 return;
486 }
487
488 http->doCallouts();
489}
490
491static void
492icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data)
493{
494 ClientRequestContext *calloutContext = (ClientRequestContext *)data;
495
496 if (!calloutContext->httpStateIsValid())
497 return;
498
499 calloutContext->icapAclCheckDone(service);
500}
501
502void
503ClientRequestContext::icapAclCheckDone(ICAPServiceRep::Pointer service)
504{
6ec67de9 505 debugs(93,3,HERE << this << " icapAclCheckDone called");
de31d06f 506 /*
507 * No matching ICAP service in the config file
508 */
509
510 if (service == NULL) {
511 http->doCallouts();
512 return;
513 }
514
515 /*
516 * Setup ICAP state and such. If successful, just return.
517 * We'll get back to doCallouts() after REQMOD is done.
518 */
6ec67de9 519 assert(http);
520
de31d06f 521 if (0 == http->doIcap(service))
522 return;
523
524 /*
525 * If doIcap() fails, then we have to either return an error
526 * to the user, or keep going without ICAP.
527 */
528 fatal("Fix this case in ClientRequestContext::icapAclCheckDone()");
c99de607 529 // And when fixed, check whether the service is down in doIcap and
530 // if it is, abort early, without creating ICAPClientReqmodPrecache.
531 // See Server::startIcap() and its use.
de31d06f 532
533 http->doCallouts();
edce4d98 534}
535
de31d06f 536#endif
537
14cc8559 538static void
539clientRedirectAccessCheckDone(int answer, void *data)
540{
541 ClientRequestContext *context = (ClientRequestContext *)data;
59a1efb2 542 ClientHttpRequest *http = context->http;
14cc8559 543 context->acl_checklist = NULL;
544
545 if (answer == ACCESS_ALLOWED)
de31d06f 546 redirectStart(http, clientRedirectDoneWrapper, context);
14cc8559 547 else
de31d06f 548 context->clientRedirectDone(NULL);
14cc8559 549}
550
de31d06f 551void
552ClientRequestContext::clientRedirectStart()
14cc8559 553{
14cc8559 554 debug(33, 5) ("clientRedirectStart: '%s'\n", http->uri);
555
14cc8559 556 if (Config.accessList.redirector) {
de31d06f 557 acl_checklist = clientAclChecklistCreate(Config.accessList.redirector, http);
558 acl_checklist->nonBlockingCheck(clientRedirectAccessCheckDone, this);
14cc8559 559 } else
de31d06f 560 redirectStart(http, clientRedirectDoneWrapper, this);
14cc8559 561}
562
edce4d98 563static int
59a1efb2 564clientHierarchical(ClientHttpRequest * http)
edce4d98 565{
566 const char *url = http->uri;
190154cf 567 HttpRequest *request = http->request;
edce4d98 568 method_t method = request->method;
569 const wordlist *p = NULL;
570
69660be0 571 /*
572 * IMS needs a private key, so we can use the hierarchy for IMS only if our
573 * neighbors support private keys
574 */
62e76326 575
edce4d98 576 if (request->flags.ims && !neighbors_do_private_keys)
62e76326 577 return 0;
578
69660be0 579 /*
580 * This is incorrect: authenticating requests can be sent via a hierarchy
06b97e72 581 * (they can even be cached if the correct headers are set on the reply)
edce4d98 582 */
583 if (request->flags.auth)
62e76326 584 return 0;
585
edce4d98 586 if (method == METHOD_TRACE)
62e76326 587 return 1;
588
edce4d98 589 if (method != METHOD_GET)
62e76326 590 return 0;
591
edce4d98 592 /* scan hierarchy_stoplist */
593 for (p = Config.hierarchy_stoplist; p; p = p->next)
62e76326 594 if (strstr(url, p->key))
595 return 0;
596
edce4d98 597 if (request->flags.loopdetect)
62e76326 598 return 0;
599
edce4d98 600 if (request->protocol == PROTO_HTTP)
62e76326 601 return httpCachable(method);
602
edce4d98 603 if (request->protocol == PROTO_GOPHER)
62e76326 604 return gopherCachable(request);
605
edce4d98 606 if (request->protocol == PROTO_WAIS)
62e76326 607 return 0;
608
edce4d98 609 if (request->protocol == PROTO_CACHEOBJ)
62e76326 610 return 0;
611
edce4d98 612 return 1;
613}
614
615
616static void
59a1efb2 617clientInterpretRequestHeaders(ClientHttpRequest * http)
edce4d98 618{
190154cf 619 HttpRequest *request = http->request;
0ef77270 620 HttpHeader *req_hdr = &request->header;
edce4d98 621 int no_cache = 0;
a787b56a 622#if !(ESI) || defined(USE_USERAGENT_LOG) || defined(USE_REFERER_LOG)
62e76326 623
edce4d98 624 const char *str;
625#endif
62e76326 626
edce4d98 627 request->imslen = -1;
a9925b40 628 request->ims = req_hdr->getTime(HDR_IF_MODIFIED_SINCE);
62e76326 629
edce4d98 630 if (request->ims > 0)
62e76326 631 request->flags.ims = 1;
632
edce4d98 633#if ESI
69660be0 634 /*
635 * We ignore Cache-Control as per the Edge Architecture Section 3. See
636 * www.esi.org for more information.
edce4d98 637 */
638#else
62e76326 639
a9925b40 640 if (req_hdr->has(HDR_PRAGMA)) {
641 String s = req_hdr->getList(HDR_PRAGMA);
62e76326 642
643 if (strListIsMember(&s, "no-cache", ','))
644 no_cache++;
645
646 s.clean();
edce4d98 647 }
62e76326 648
edce4d98 649 if (request->cache_control)
62e76326 650 if (EBIT_TEST(request->cache_control->mask, CC_NO_CACHE))
651 no_cache++;
652
69660be0 653 /*
62e76326 654 * Work around for supporting the Reload button in IE browsers when Squid
655 * is used as an accelerator or transparent proxy, by turning accelerated
656 * IMS request to no-cache requests. Now knows about IE 5.5 fix (is
657 * actually only fixed in SP1, but we can't tell whether we are talking to
658 * SP1 or not so all 5.5 versions are treated 'normally').
659 */
edce4d98 660 if (Config.onoff.ie_refresh) {
62e76326 661 if (http->flags.accel && request->flags.ims) {
a9925b40 662 if ((str = req_hdr->getStr(HDR_USER_AGENT))) {
62e76326 663 if (strstr(str, "MSIE 5.01") != NULL)
664 no_cache++;
665 else if (strstr(str, "MSIE 5.0") != NULL)
666 no_cache++;
667 else if (strstr(str, "MSIE 4.") != NULL)
668 no_cache++;
669 else if (strstr(str, "MSIE 3.") != NULL)
670 no_cache++;
671 }
672 }
edce4d98 673 }
62e76326 674
edce4d98 675#endif
676 if (no_cache) {
677#if HTTP_VIOLATIONS
62e76326 678
679 if (Config.onoff.reload_into_ims)
680 request->flags.nocache_hack = 1;
681 else if (refresh_nocache_hack)
682 request->flags.nocache_hack = 1;
683 else
edce4d98 684#endif
62e76326 685
686 request->flags.nocache = 1;
edce4d98 687 }
62e76326 688
0ef77270 689 /* ignore range header in non-GETs or non-HEADs */
690 if (request->method == METHOD_GET || request->method == METHOD_HEAD) {
a9925b40 691 request->range = req_hdr->getRange();
62e76326 692
693 if (request->range) {
694 request->flags.range = 1;
695 clientStreamNode *node = (clientStreamNode *)http->client_stream.tail->data;
696 /* XXX: This is suboptimal. We should give the stream the range set,
697 * and thereby let the top of the stream set the offset when the
698 * size becomes known. As it is, we will end up requesting from 0
699 * for evey -X range specification.
700 * RBC - this may be somewhat wrong. We should probably set the range
701 * iter up at this point.
702 */
703 node->readBuffer.offset = request->range->lowestOffset(0);
704 http->range_iter.pos = request->range->begin();
705 http->range_iter.valid = true;
706 }
edce4d98 707 }
62e76326 708
0ef77270 709 /* Only HEAD and GET requests permit a Range or Request-Range header.
710 * If these headers appear on any other type of request, delete them now.
711 */
712 else {
713 req_hdr->delById(HDR_RANGE);
714 req_hdr->delById(HDR_REQUEST_RANGE);
715 request->range = NULL;
716 }
717
a9925b40 718 if (req_hdr->has(HDR_AUTHORIZATION))
62e76326 719 request->flags.auth = 1;
720
edce4d98 721 if (request->login[0] != '\0')
62e76326 722 request->flags.auth = 1;
723
a9925b40 724 if (req_hdr->has(HDR_VIA)) {
725 String s = req_hdr->getList(HDR_VIA);
62e76326 726 /*
727 * ThisCache cannot be a member of Via header, "1.0 ThisCache" can.
728 * Note ThisCache2 has a space prepended to the hostname so we don't
729 * accidentally match super-domains.
730 */
731
732 if (strListIsSubstr(&s, ThisCache2, ',')) {
733 debugObj(33, 1, "WARNING: Forwarding loop detected for:\n",
734 request, (ObjPackMethod) & httpRequestPack);
735 request->flags.loopdetect = 1;
736 }
737
edce4d98 738#if FORW_VIA_DB
62e76326 739 fvdbCountVia(s.buf());
740
edce4d98 741#endif
62e76326 742
743 s.clean();
edce4d98 744 }
62e76326 745
edce4d98 746#if USE_USERAGENT_LOG
a9925b40 747 if ((str = req_hdr->getStr(HDR_USER_AGENT)))
7928e475 748 logUserAgent(fqdnFromAddr(http->getConn().getRaw() ? http->getConn()->log_addr : no_addr), str);
62e76326 749
edce4d98 750#endif
751#if USE_REFERER_LOG
62e76326 752
a9925b40 753 if ((str = req_hdr->getStr(HDR_REFERER)))
7928e475 754 logReferer(fqdnFromAddr(http->getConn().getRaw() ? http->getConn()->log_addr : no_addr), str, http->log_uri);
62e76326 755
edce4d98 756#endif
757#if FORW_VIA_DB
62e76326 758
a9925b40 759 if (req_hdr->has(HDR_X_FORWARDED_FOR)) {
760 String s = req_hdr->getList(HDR_X_FORWARDED_FOR);
62e76326 761 fvdbCountForw(s.buf());
762 s.clean();
edce4d98 763 }
62e76326 764
edce4d98 765#endif
766 if (request->method == METHOD_TRACE) {
a9925b40 767 request->max_forwards = req_hdr->getInt(HDR_MAX_FORWARDS);
edce4d98 768 }
62e76326 769
610ee341 770 request->flags.cachable = http->request->cacheable();
62e76326 771
edce4d98 772 if (clientHierarchical(http))
62e76326 773 request->flags.hierarchical = 1;
774
edce4d98 775 debug(85, 5) ("clientInterpretRequestHeaders: REQ_NOCACHE = %s\n",
62e76326 776 request->flags.nocache ? "SET" : "NOT SET");
777
edce4d98 778 debug(85, 5) ("clientInterpretRequestHeaders: REQ_CACHABLE = %s\n",
62e76326 779 request->flags.cachable ? "SET" : "NOT SET");
780
edce4d98 781 debug(85, 5) ("clientInterpretRequestHeaders: REQ_HIERARCHICAL = %s\n",
62e76326 782 request->flags.hierarchical ? "SET" : "NOT SET");
edce4d98 783}
784
785void
de31d06f 786clientRedirectDoneWrapper(void *data, char *result)
edce4d98 787{
de31d06f 788 ClientRequestContext *calloutContext = (ClientRequestContext *)data;
db02222f 789
de31d06f 790 if (!calloutContext->httpStateIsValid())
62e76326 791 return;
62e76326 792
de31d06f 793 calloutContext->clientRedirectDone(result);
794}
795
796void
797ClientRequestContext::clientRedirectDone(char *result)
798{
190154cf 799 HttpRequest *new_request = NULL;
800 HttpRequest *old_request = http->request;
edce4d98 801 debug(85, 5) ("clientRedirectDone: '%s' result=%s\n", http->uri,
62e76326 802 result ? result : "NULL");
de31d06f 803 assert(redirect_state == REDIRECT_PENDING);
804 redirect_state = REDIRECT_DONE;
62e76326 805
edce4d98 806 if (result) {
62e76326 807 http_status status = (http_status) atoi(result);
808
809 if (status == HTTP_MOVED_PERMANENTLY
810 || status == HTTP_MOVED_TEMPORARILY
811 || status == HTTP_SEE_OTHER
812 || status == HTTP_TEMPORARY_REDIRECT) {
813 char *t = result;
814
815 if ((t = strchr(result, ':')) != NULL) {
816 http->redirect.status = status;
817 http->redirect.location = xstrdup(t + 1);
818 } else {
819 debug(85, 1) ("clientRedirectDone: bad input: %s\n", result);
820 }
2baf58c3 821 } else if (strcmp(result, http->uri))
c21ad0f5 822 new_request = HttpRequest::CreateFromUrlAndMethod(result, old_request->method);
edce4d98 823 }
62e76326 824
edce4d98 825 if (new_request) {
62e76326 826 safe_free(http->uri);
827 http->uri = xstrdup(urlCanonical(new_request));
828 new_request->http_ver = old_request->http_ver;
a9925b40 829 new_request->header.append(&old_request->header);
62e76326 830 new_request->client_addr = old_request->client_addr;
47b0c1fa 831 new_request->client_port = old_request->client_port;
62e76326 832 new_request->my_addr = old_request->my_addr;
833 new_request->my_port = old_request->my_port;
834 new_request->flags = old_request->flags;
3c1f01bc 835 new_request->flags.redirected = 1;
62e76326 836
837 if (old_request->auth_user_request) {
838 new_request->auth_user_request = old_request->auth_user_request;
f5691f9c 839
840 new_request->auth_user_request->lock()
841
842 ;
62e76326 843 }
844
3b299123 845 if (old_request->body_reader != NULL) {
846 new_request->body_reader = old_request->body_reader;
847 old_request->body_reader = NULL;
848 debugs(0,0,HERE << "setting body_reader = NULL for request " << old_request);
62e76326 849 }
850
851 new_request->content_length = old_request->content_length;
abb929f0 852 new_request->extacl_user = old_request->extacl_user;
853 new_request->extacl_passwd = old_request->extacl_passwd;
62e76326 854 new_request->flags.proxy_keepalive = old_request->flags.proxy_keepalive;
6dd9f4bd 855 HTTPMSGUNLOCK(old_request);
856 http->request = HTTPMSGLOCK(new_request);
edce4d98 857 }
62e76326 858
edce4d98 859 /* FIXME PIPELINE: This is innacurate during pipelining */
62e76326 860
a2ac85d9 861 if (http->getConn().getRaw() != NULL)
98242069 862 fd_note(http->getConn()->fd, http->uri);
62e76326 863
c8be6d7b 864 assert(http->uri);
62e76326 865
de31d06f 866 http->doCallouts();
edce4d98 867}
868
869void
8e2745f4 870ClientRequestContext::checkNoCache()
edce4d98 871{
de31d06f 872 acl_checklist = clientAclChecklistCreate(Config.accessList.noCache, http);
57abaac0 873 acl_checklist->nonBlockingCheck(checkNoCacheDoneWrapper, this);
edce4d98 874}
875
de31d06f 876static void
877checkNoCacheDoneWrapper(int answer, void *data)
edce4d98 878{
de31d06f 879 ClientRequestContext *calloutContext = (ClientRequestContext *) data;
e4a67a80 880
de31d06f 881 if (!calloutContext->httpStateIsValid())
882 return;
883
884 calloutContext->checkNoCacheDone(answer);
8e2745f4 885}
4fb35c3c 886
8e2745f4 887void
888ClientRequestContext::checkNoCacheDone(int answer)
62e76326 889{
8e2745f4 890 acl_checklist = NULL;
de31d06f 891 http->request->flags.cachable = answer;
892 http->doCallouts();
edce4d98 893}
894
69660be0 895/*
896 * Identify requests that do not go through the store and client side stream
897 * and forward them to the appropriate location. All other requests, request
898 * them.
edce4d98 899 */
900void
8e2745f4 901ClientHttpRequest::processRequest()
edce4d98 902{
edce4d98 903 debug(85, 4) ("clientProcessRequest: %s '%s'\n",
62e76326 904 RequestMethodStr[request->method], uri);
905
2baf58c3 906 if (request->method == METHOD_CONNECT && !redirect.status) {
62e76326 907 logType = LOG_TCP_MISS;
908 sslStart(this, &out.size, &al.http.code);
909 return;
edce4d98 910 }
62e76326 911
8e2745f4 912 httpStart();
913}
914
915void
916ClientHttpRequest::httpStart()
917{
559da936 918 PROF_start(httpStart);
8e2745f4 919 logType = LOG_TAG_NONE;
920 debug(85, 4) ("ClientHttpRequest::httpStart: %s for '%s'\n",
62e76326 921 log_tags[logType], uri);
edce4d98 922 /* no one should have touched this */
8e2745f4 923 assert(out.offset == 0);
edce4d98 924 /* Use the Stream Luke */
8e2745f4 925 clientStreamNode *node = (clientStreamNode *)client_stream.tail->data;
926 clientStreamRead(node, this, node->readBuffer);
559da936 927 PROF_stop(httpStart);
edce4d98 928}
0655fa4d 929
930bool
931ClientHttpRequest::gotEnough() const
932{
86a2f789 933 /** TODO: should be querying the stream. */
0655fa4d 934 int contentLength =
06a5ae20 935 memObject()->getReply()->bodySize(request->method);
0655fa4d 936 assert(contentLength >= 0);
937
938 if (out.offset < contentLength)
939 return false;
940
941 return true;
942}
943
b51aec66 944void
945ClientHttpRequest::maxReplyBodySize(ssize_t clen)
946{
947 maxReplyBodySize_ = clen;
948}
949
950ssize_t
951ClientHttpRequest::maxReplyBodySize() const
952{
953 return maxReplyBodySize_;
954}
955
956bool
957ClientHttpRequest::isReplyBodyTooLarge(ssize_t clen) const
958{
959 if (0 == maxReplyBodySize())
960 return 0; /* disabled */
961
962 if (clen < 0)
963 return 0; /* unknown */
964
965 return clen > maxReplyBodySize();
966}
86a2f789 967
968void
969ClientHttpRequest::storeEntry(StoreEntry *newEntry)
970{
971 entry_ = newEntry;
972}
973
0976f8db 974void
975ClientHttpRequest::loggingEntry(StoreEntry *newEntry)
976{
977 if (loggingEntry_)
97b5e68f 978 loggingEntry_->unlock();
0976f8db 979
980 loggingEntry_ = newEntry;
981
982 if (loggingEntry_)
34266cde 983 loggingEntry_->lock()
984
985 ;
0976f8db 986}
86a2f789 987
de31d06f 988/*
989 * doCallouts() - This function controls the order of "callout"
990 * executions, including non-blocking access control checks, the
991 * redirector, and ICAP. Previously, these callouts were chained
992 * together such that "clientAccessCheckDone()" would call
993 * "clientRedirectStart()" and so on.
994 *
995 * The ClientRequestContext (aka calloutContext) class holds certain
996 * state data for the callout/callback operations. Previously
997 * ClientHttpRequest would sort of hand off control to ClientRequestContext
998 * for a short time. ClientRequestContext would then delete itself
999 * and pass control back to ClientHttpRequest when all callouts
1000 * were finished.
1001 *
1002 * This caused some problems for ICAP because we want to make the
1003 * ICAP callout after checking ACLs, but before checking the no_cache
1004 * list. We can't stuff the ICAP state into the ClientRequestContext
1005 * class because we still need the ICAP state after ClientRequestContext
1006 * goes away.
1007 *
1008 * Note that ClientRequestContext is created before the first call
1009 * to doCallouts().
1010 *
1011 * If one of the callouts notices that ClientHttpRequest is no
1012 * longer valid, it should call cbdataReferenceDone() so that
1013 * ClientHttpRequest's reference count goes to zero and it will get
1014 * deleted. ClientHttpRequest will then delete ClientRequestContext.
1015 *
1016 * Note that we set the _done flags here before actually starting
1017 * the callout. This is strictly for convenience.
1018 */
1019
1020void
1021ClientHttpRequest::doCallouts()
1022{
1023 assert(calloutContext);
1024
1025 if (!calloutContext->http_access_done) {
57abaac0 1026 calloutContext->http_access_done = true;
de31d06f 1027 calloutContext->clientAccessCheck();
1028 return;
1029 }
1030
1031#if ICAP_CLIENT
ab7ac359 1032 if (TheICAPConfig.onoff && !calloutContext->icap_acl_check_done) {
57abaac0 1033 calloutContext->icap_acl_check_done = true;
de31d06f 1034 calloutContext->icapAccessCheck();
1035 return;
1036 }
1037
1038#endif
1039
1040 if (!calloutContext->redirect_done) {
57abaac0 1041 calloutContext->redirect_done = true;
de31d06f 1042 assert(calloutContext->redirect_state == REDIRECT_NONE);
1043
1044 if (Config.Program.redirect) {
1045 calloutContext->redirect_state = REDIRECT_PENDING;
1046 calloutContext->clientRedirectStart();
1047 return;
1048 }
1049 }
1050
57abaac0 1051 if (!calloutContext->interpreted_req_hdrs) {
1052 calloutContext->interpreted_req_hdrs = 1;
1053 clientInterpretRequestHeaders(this);
1054 }
1055
de31d06f 1056 if (!calloutContext->no_cache_done) {
57abaac0 1057 calloutContext->no_cache_done = true;
de31d06f 1058
1059 if (Config.accessList.noCache && request->flags.cachable) {
1060 calloutContext->checkNoCache();
1061 return;
1062 }
1063 }
1064
1065 cbdataReferenceDone(calloutContext->http);
1066 delete calloutContext;
1067 calloutContext = NULL;
de31d06f 1068#if HEADERS_LOG
1069
1070 headersLog(0, 1, request->method, request);
1071#endif
1072
1073 processRequest();
1074}
1075
86a2f789 1076#ifndef _USE_INLINE_
1077#include "client_side_request.cci"
1078#endif
de31d06f 1079
1080#if ICAP_CLIENT
1081/*
1082 * Initiate an ICAP transaction. Return 0 if all is well, or -1 upon error.
1083 * Caller will handle error condition by generating a Squid error message
1084 * or take other action.
1085 */
1086int
1087ClientHttpRequest::doIcap(ICAPServiceRep::Pointer service)
1088{
0b86805b 1089 debugs(85, 3, HERE << this << " ClientHttpRequest::doIcap() called");
de31d06f 1090 assert(NULL == icap);
1091 icap = new ICAPClientReqmodPrecache(service);
de31d06f 1092 icap->startReqMod(this, request);
3b299123 1093
1094 if (request->body_reader == NULL) {
0b86805b 1095 debugs(32, 3, HERE << "client request hasnt body...");
3b299123 1096 icap->doneSending();
1097
1098 }
1099
de31d06f 1100 return 0;
1101}
1102
3b299123 1103/*
1104 * icapSendRequestBodyWrapper
1105 *
1106 * A callback wrapper for ::icapSendRequestBody()
1107 *
1108 * icapSendRequestBodyWrapper is of type CBCB
1109 */
1110void
1111ClientHttpRequest::icapSendRequestBodyWrapper(MemBuf &mb, void *data)
1112{
1113 ClientHttpRequest *chr = static_cast<ClientHttpRequest*>(data);
1114 chr->icapSendRequestBody(mb);
1115}
1116
1117
1118/*
1119 * icapSendRequestBody
1120 *
1121 * Sends some chunk of a request body to the ICAP side. Must make sure
1122 * that the ICAP-side can accept the data we have. If there is more
1123 * body data to read, then schedule another BodyReader callback.
1124 */
1125void
1126ClientHttpRequest::icapSendRequestBody(MemBuf &mb)
1127{
1128 ssize_t size_to_send = mb.contentSize();
1129 debugs(32,3,HERE << "have " << mb.contentSize() << " bytes in mb");
1130
1131 if (size_to_send == 0) {
1132 /*
1133 * An error occurred during this transaction. Tell ICAP that we're done.
1134 */
1135
1136 if (icap)
1137 icap->doneSending();
1138
1139 return;
1140 }
1141
1142 debugs(32,3,HERE << "icap->potentialSpaceSize() = " << icap->potentialSpaceSize());
1143
1144 if (size_to_send > icap->potentialSpaceSize())
1145 size_to_send = icap->potentialSpaceSize();
1146
1147 if (size_to_send) {
1148 debugs(32,3,HERE << "sending " << size_to_send << " body bytes to ICAP");
1149 StoreIOBuffer sbuf(size_to_send, 0, mb.content());
1150 icap->sendMoreData(sbuf);
1151 icap->body_reader->consume(size_to_send);
1152 icap->body_reader->bytes_read += size_to_send;
1153 debugs(32,3," HTTP client body bytes_read=" << icap->body_reader->bytes_read);
1154 } else {
c99de607 1155 debugs(32,2,HERE << "cannot send body data to ICAP");
1156 debugs(32,2,HERE << "\tBodyReader MemBuf has " << mb.contentSize());
1157 debugs(32,2,HERE << "\tbut icap->potentialSpaceSize() is " << icap->potentialSpaceSize());
3b299123 1158 return;
1159 }
1160
1161 /*
1162 * If we sent some data this time, and there is more data to
1163 * read, then schedule another read request via BodyReader.
1164 */
1165 if (size_to_send && icap->body_reader->remaining()) {
1166 debugs(32,3,HERE << "calling body_reader->read()");
1167 icap->body_reader->read(icapSendRequestBodyWrapper, this);
1168 } else {
1169 debugs(32,3,HERE << "No more request body bytes to send");
1170 icap->doneSending();
1171 }
1172}
1173
de31d06f 1174/*
1175 * Called by ICAPAnchor when it has space available for us.
1176 */
1177void
1178ClientHttpRequest::icapSpaceAvailable()
1179{
3b299123 1180 debugs(85,3,HERE << this << " ClientHttpRequest::icapSpaceAvailable() called\n");
1181
1182 if (request->body_reader != NULL && icap->body_reader == NULL) {
1183 debugs(32,3,HERE << "reassigning HttpRequest->body_reader to ICAP");
1184 /*
1185 * ICAP hooks on to the BodyReader that gets data from
1186 * ConnStateData. We'll make a new BodyReader that
1187 * HttpStateData can use if the adapted response has a
1188 * request body. See ICAPClientReqmodPrecache::noteSourceStart()
1189 */
1190 icap->body_reader = request->body_reader;
1191 request->body_reader = NULL;
1192 }
1193
1194 if (icap->body_reader == NULL)
1195 return;
1196
1197 if (icap->body_reader->callbackPending())
1198 return;
1199
1200 debugs(32,3,HERE << "Calling read() for body data");
1201
1202 icap->body_reader->read(icapSendRequestBodyWrapper, this);
de31d06f 1203}
1204
1205void
1206ClientHttpRequest::takeAdaptedHeaders(HttpMsg *msg)
1207{
1208 debug(85,3)("ClientHttpRequest::takeAdaptedHeaders() called\n");
1209 assert(cbdataReferenceValid(this)); // indicates bug
1210
b044675d 1211 if (HttpRequest *new_req = dynamic_cast<HttpRequest*>(msg)) {
200ac359 1212 /*
1213 * Replace the old request with the new request. First,
1214 * Move the "body_connection" over, then unlink old and
1215 * link new to the http state.
1216 */
6dd9f4bd 1217 HTTPMSGUNLOCK(request);
1218 request = HTTPMSGLOCK(new_req);
200ac359 1219 /*
1220 * Store the new URI for logging
1221 */
1222 xfree(uri);
1223 uri = xstrdup(urlCanonical(request));
1224 setLogUri(this, urlCanonicalClean(request));
1225 assert(request->method);
b044675d 1226 } else if (HttpReply *new_rep = dynamic_cast<HttpReply*>(msg)) {
1227 debugs(85,3,HERE << "REQMOD reply is HTTP reply");
1228
1229 clientStreamNode *node = (clientStreamNode *)client_stream.tail->prev->data;
1230 clientReplyContext *repContext = dynamic_cast<clientReplyContext *>(node->data.getRaw());
1231 repContext->createStoreEntry(request->method, request->flags);
1232
1233 EBIT_CLR(storeEntry()->flags, ENTRY_FWD_HDR_WAIT);
1234 request_satisfaction_mode = true;
1235 request_satisfaction_offset = 0;
1236 storeEntry()->replaceHttpReply(new_rep);
1237 clientGetMoreData(node, this);
200ac359 1238 }
de31d06f 1239
b044675d 1240 if (!request_satisfaction_mode)
1241 doCallouts();
de31d06f 1242
1243 debug(85,3)("ClientHttpRequest::takeAdaptedHeaders() finished\n");
1244}
1245
1246void
1247ClientHttpRequest::takeAdaptedBody(MemBuf *buf)
1248{
1249 debug(85,3)("ClientHttpRequest::takeAdaptedBody() called\n");
b044675d 1250
1251 if (request_satisfaction_mode) {
1252 storeEntry()->write(StoreIOBuffer(buf, request_satisfaction_offset));
1253 request_satisfaction_offset += buf->contentSize();
1254 buf->consume(buf->contentSize()); // consume everything written
310afc6c 1255 } else {
1256 debug(85,0)("Unexpected call to takeAdaptedBody when "
1257 "not in request_satisfaction_mode");
b044675d 1258 }
de31d06f 1259}
1260
1261void
1262ClientHttpRequest::doneAdapting()
1263{
1264 debug(85,3)("ClientHttpRequest::doneAdapting() called\n");
1265}
1266
1267void
1268ClientHttpRequest::abortAdapting()
1269{
1270 debug(85,3)("ClientHttpRequest::abortAdapting() called\n");
1271
1272 if ((NULL == storeEntry()) || storeEntry()->isEmpty()) {
1273 debug(85,3)("WARNING: ICAP REQMOD callout failed, proceeding with original request\n");
3b299123 1274
1275 if (calloutContext)
1276 doCallouts();
1277
de31d06f 1278#if ICAP_HARD_ERROR
1279
1280 clientStreamNode *node = (clientStreamNode *)client_stream.tail->prev->data;
3b299123 1281
de31d06f 1282 clientReplyContext *repContext = dynamic_cast<clientReplyContext *>(node->data.getRaw());
3b299123 1283
de31d06f 1284 assert (repContext);
3b299123 1285
de31d06f 1286 // Note if this code is ever used, clientBuildError() should be modified to
1287 // accept an errno arg
1288 repContext->setReplyToError(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR,
1289 request->method, NULL,
1290 getConn().getRaw() != NULL ? &getConn()->peer.sin_addr : &no_addr, request,
1291 NULL, getConn().getRaw() != NULL
1292 && getConn()->auth_user_request ? getConn()->
1293 auth_user_request : request->auth_user_request, errno);
3b299123 1294
de31d06f 1295 node = (clientStreamNode *)client_stream.tail->data;
3b299123 1296
de31d06f 1297 clientStreamRead(node, this, node->readBuffer);
3b299123 1298
de31d06f 1299#endif
1300
1301 return;
1302 }
1303
1304 debug(0,0)("write me at %s:%d\n", __FILE__,__LINE__);
1305}
1306
1307#endif