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