client_side_reply.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9/* DEBUG: section 88 Client-side Reply Routines */
10
11#include "squid.h"
12#include "acl/FilledChecklist.h"
13#include "acl/Gadgets.h"
14#include "anyp/PortCfg.h"
15#include "client_side_reply.h"
16#include "errorpage.h"
17#include "ETag.h"
18#include "fd.h"
19#include "fde.h"
20#include "format/Token.h"
21#include "FwdState.h"
22#include "globals.h"
23#include "http/Stream.h"
24#include "HttpHeaderTools.h"
25#include "HttpReply.h"
26#include "HttpRequest.h"
27#include "ip/QosConfig.h"
28#include "ipcache.h"
29#include "log/access_log.h"
30#include "MemObject.h"
31#include "mime_header.h"
32#include "neighbors.h"
33#include "refresh.h"
34#include "RequestFlags.h"
35#include "SquidConfig.h"
36#include "SquidMath.h"
37#include "Store.h"
38#include "StrList.h"
39#include "tools.h"
40#if USE_AUTH
41#include "auth/UserRequest.h"
42#endif
43#if USE_DELAY_POOLS
44#include "DelayPools.h"
45#endif
46#if USE_SQUID_ESI
47#include "esi/Esi.h"
48#endif
49
50#include <memory>
51
53
54/* Local functions */
57
58/* privates */
59
61{
62 deleting = true;
63 /* This may trigger a callback back into SendMoreData as the cbdata
64 * is still valid
65 */
67 /* old_entry might still be set if we didn't yet get the reply
68 * code in HandleIMSReply() */
72}
73
75 purgeStatus(Http::scNone),
76 http(cbdataReference(clientContext)),
77 sc(nullptr),
78 ourNode(nullptr),
79 reply(nullptr),
80 old_entry(nullptr),
81 old_sc(nullptr),
82 old_lastmod(-1),
83 deleting(false),
84 collapsedRevalidation(crNone)
85{
86 *tempbuf = 0;
87}
88
94void
96 err_type err, Http::StatusCode status, char const *uri,
97 const ConnStateData *conn, HttpRequest *failedrequest, const char *unparsedrequest,
98#if USE_AUTH
99 Auth::UserRequest::Pointer auth_user_request
100#else
101 void*
102#endif
103)
104{
105 auto errstate = clientBuildError(err, status, uri, conn, failedrequest, http->al);
106
107 if (unparsedrequest)
108 errstate->request_hdrs = xstrdup(unparsedrequest);
109
110#if USE_AUTH
111 errstate->auth_user_request = auth_user_request;
112#endif
113 setReplyToError(failedrequest ? failedrequest->method : HttpRequestMethod(Http::METHOD_NONE), errstate);
114}
115
117{
118 if (errstate->httpStatus == Http::scNotImplemented && http->request)
119 /* prevent confusion over whether we default to persistent or not */
121
122 http->al->http.code = errstate->httpStatus;
123
124 if (http->request)
125 http->request->ignoreRange("responding with a Squid-generated error");
126
128 assert(errstate->callback_data == nullptr);
129 errorAppendEntry(http->storeEntry(), errstate);
130 /* Now the caller reads to get this */
131}
132
133void
135{
136 Must(futureReply);
137 http->al->http.code = futureReply->sline.status();
138
139 HttpRequestMethod method;
140 if (http->request) { // nil on responses to unparsable requests
141 http->request->ignoreRange("responding with a Squid-generated reply");
142 method = http->request->method;
143 }
144
146
147 http->storeEntry()->storeErrorResponse(futureReply);
148 /* Now the caller reads to get futureReply */
149}
150
151// Assumes that the entry contains an error response without Content-Range.
152// To use with regular entries, make HTTP Range header removal conditional.
154{
155 entry->lock("clientReplyContext::setReplyToStoreEntry"); // removeClientStoreReference() unlocks
156 sc = storeClientListAdd(entry, this);
157#if USE_DELAY_POOLS
159#endif
160 if (http->request)
161 http->request->ignoreRange(reason);
163 http->storeEntry(entry);
164}
165
166void
168 StoreEntry ** ep)
169{
170 StoreEntry *e;
171 store_client *sc_tmp = *scp;
172
173 if ((e = *ep) != nullptr) {
174 *ep = nullptr;
175 storeUnregister(sc_tmp, e, this);
176 *scp = nullptr;
177 e->unlock("clientReplyContext::removeStoreReference");
178 }
179}
180
181void
183{
184 StoreEntry *reference = aHttpRequest->storeEntry();
185 removeStoreReference(scp, &reference);
186 aHttpRequest->storeEntry(reference);
187}
188
189void
191{
192 assert(old_sc == nullptr);
193 debugs(88, 3, "clientReplyContext::saveState: saving store context");
195 old_sc = sc;
198 /* Prevent accessing the now saved entries */
199 http->storeEntry(nullptr);
200 sc = nullptr;
201}
202
203void
205{
206 assert(old_sc != nullptr);
207 debugs(88, 3, "clientReplyContext::restoreState: Restoring store context");
210 sc = old_sc;
213 /* Prevent accessed the old saved entries */
214 old_entry = nullptr;
215 old_sc = nullptr;
216 old_lastmod = -1;
217 old_etag.clean();
218}
219
220void
222{
226}
227
230{
232}
233
237void
239{
240 Assure(recipient != HandleIMSReply);
241 lastStreamBufferedBytes = StoreIOBuffer(); // storeClientCopy(next()->readBuffer) invalidates
242 StoreIOBuffer localTempBuffer (next()->readBuffer.length, 0, next()->readBuffer.data);
243 ::storeClientCopy(sc, http->storeEntry(), localTempBuffer, recipient, this);
244}
245
250void
252{
253 lastStreamBufferedBytes = StoreIOBuffer(); // storeClientCopy(next()->readBuffer) invalidates
254 ::storeClientCopy(sc, http->storeEntry(), next()->readBuffer, SendMoreData, this);
255}
256
257/* there is an expired entry in the store.
258 * setup a temporary buffer area and perform an IMS to the origin
259 */
260void
262{
263 const char *url = storeId();
264 debugs(88, 3, "clientReplyContext::processExpired: '" << http->uri << "'");
265 const time_t lastmod = http->storeEntry()->lastModified();
266 assert(lastmod >= 0);
267 /*
268 * check if we are allowed to contact other servers
269 * @?@: Instead of a 504 (Gateway Timeout) reply, we may want to return
270 * a stale entry *if* it matches client requirements
271 */
272
273 if (http->onlyIfCached()) {
275 return;
276 }
277
279 http->request->flags.refresh = true;
280#if STORE_CLIENT_LIST_DEBUG
281 /* Prevent a race with the store client memory free routines
282 */
284#endif
285 /* Prepare to make a new temporary request */
286 saveState();
287
288 // TODO: Consider also allowing regular (non-collapsed) revalidation hits.
289 // TODO: support collapsed revalidation for Vary-controlled entries
290 bool collapsingAllowed = Config.onoff.collapsed_forwarding &&
293
294 StoreEntry *entry = nullptr;
295 if (collapsingAllowed) {
296 if (const auto e = storeGetPublicByRequest(http->request, ksRevalidation)) {
297 if (e->hittingRequiresCollapsing() && startCollapsingOn(*e, true)) {
298 entry = e;
299 entry->lock("clientReplyContext::processExpired#alreadyRevalidating");
300 } else {
301 e->abandon(__FUNCTION__);
302 // assume mayInitiateCollapsing() would fail too
303 collapsingAllowed = false;
304 }
305 }
306 }
307
308 if (entry) {
310 debugs(88, 5, "collapsed on existing revalidation entry: " << *entry);
312 } else {
313 entry = storeCreateEntry(url,
315 /* NOTE, don't call StoreEntry->lock(), storeCreateEntry() does it */
316
317 if (collapsingAllowed && mayInitiateCollapsing() &&
318 Store::Root().allowCollapsing(entry, http->request->flags, http->request->method)) {
319 debugs(88, 5, "allow other revalidation requests to collapse on " << *entry);
321 } else {
323 }
324 }
325
326 sc = storeClientListAdd(entry, this);
327#if USE_DELAY_POOLS
328 /* delay_id is already set on original store client */
330#endif
331
332 http->request->lastmod = lastmod;
333
335 ETag etag = {nullptr, -1}; // TODO: make that a default ETag constructor
336 if (old_entry->hasEtag(etag) && !etag.weak)
337 http->request->etag = etag.str;
338 }
339
340 debugs(88, 5, "lastmod " << entry->lastModified());
341 http->storeEntry(entry);
342 assert(http->out.offset == 0);
344
346 /*
347 * A refcounted pointer so that FwdState stays around as long as
348 * this clientReplyContext does
349 */
350 Comm::ConnectionPointer conn = http->getConn() != nullptr ? http->getConn()->clientConnection : nullptr;
352 }
353 /* Register with storage manager to receive updates when data comes in. */
354
355 if (EBIT_TEST(entry->flags, ENTRY_ABORTED))
356 debugs(88, DBG_CRITICAL, "clientReplyContext::processExpired: Found ENTRY_ABORTED object");
357
358 {
359 /* start counting the length from 0 */
360 StoreIOBuffer localTempBuffer(HTTP_REQBUF_SZ, 0, tempbuf);
361 // keep lastStreamBufferedBytes: tempbuf is not a Client Stream buffer
362 ::storeClientCopy(sc, entry, localTempBuffer, HandleIMSReply, this);
363 }
364}
365
366void
368{
370
373
374 /* here the data to send is the data we just received */
376 sendMoreData(upstreamResponse);
377}
378
379void
381{
382 clientReplyContext *context = (clientReplyContext *)data;
383 context->handleIMSReply(result);
384}
385
386void
388{
389 /* Get the old request back */
390 restoreState();
391 /* here the data to send is in the next nodes buffers already */
396}
397
398/* This is the workhorse of the HandleIMSReply callback.
399 *
400 * It is called when we've got data back from the origin following our
401 * IMS request to revalidate a stale entry.
402 */
403void
405{
406 if (deleting)
407 return;
408
409 if (http->storeEntry() == nullptr)
410 return;
411
412 debugs(88, 3, http->storeEntry()->url() << " got " << result);
413
415 return;
416
418 debugs(88, 3, "CF slave hit private non-shareable " << *http->storeEntry() << ". MISS");
419 // restore context to meet processMiss() expectations
420 restoreState();
422 processMiss();
423 return;
424 }
425
426 // request to origin was aborted
428 debugs(88, 3, "request to origin aborted '" << http->storeEntry()->url() << "', sending old entry to client");
431 return;
432 }
433
434 const auto oldStatus = old_entry->mem().freshestReply().sline.status();
435 const auto &new_rep = http->storeEntry()->mem().freshestReply();
436 const auto status = new_rep.sline.status();
437
438 // XXX: Disregard stale incomplete (i.e. still being written) borrowed (i.e.
439 // not caused by our request) IMS responses. That new_rep may be very old!
440
441 // origin replied 304
442 if (status == Http::scNotModified) {
443 // TODO: The update may not be instantaneous. Should we wait for its
444 // completion to avoid spawning too much client-disassociated work?
445 if (!Store::Root().updateOnNotModified(old_entry, *http->storeEntry())) {
446 old_entry->release(true);
447 restoreState();
449 processMiss();
450 return;
451 }
452
454 http->request->flags.staleIfHit = false; // old_entry is no longer stale
455
456 // if client sent IMS
458 // forward the 304 from origin
459 debugs(88, 3, "origin replied 304, revalidated existing entry and forwarding 304 to client");
461 return;
462 }
463
464 // send existing entry, it's still valid
465 debugs(88, 3, "origin replied 304, revalidated existing entry and sending " << oldStatus << " to client");
467 return;
468 }
469
470 // origin replied with a non-error code
471 if (status > Http::scNone && status < Http::scInternalServerError) {
472 // RFC 9111 section 4:
473 // "When more than one suitable response is stored,
474 // a cache MUST use the most recent one
475 // (as determined by the Date header field)."
476 if (new_rep.olderThan(&old_entry->mem().freshestReply())) {
477 http->al->cache.code.err.ignored = true;
478 debugs(88, 3, "origin replied " << status << " but with an older date header, sending old entry (" << oldStatus << ") to client");
480 return;
481 }
482
484 debugs(88, 3, "origin replied " << status << ", forwarding to client");
486 return;
487 }
488
489 // origin replied with an error
492 debugs(88, 3, "origin replied with error " << status << ", forwarding to client due to fail_on_validation_err");
494 return;
495 }
496
497 // ignore and let client have old entry
499 debugs(88, 3, "origin replied with error " << status << ", sending old entry (" << oldStatus << ") to client");
501}
502
505
507void
509{
510 clientReplyContext *context = (clientReplyContext *)data;
511 context->cacheHit(result);
512}
513
517void
519{
521 if (deleting) {
522 debugs(88, 3, "HIT object being deleted. Ignore the HIT.");
523 return;
524 }
525
526 StoreEntry *e = http->storeEntry();
527
529
530 debugs(88, 3, http->uri << " got " << result);
531
532 if (http->storeEntry() == nullptr) {
533 debugs(88, 3, "clientCacheHit: request aborted");
534 return;
535 } else if (result.flags.error) {
536 /* swap in failure */
537 debugs(88, 3, "clientCacheHit: swapin failure for " << http->uri);
540 processMiss();
541 return;
542 }
543
544 // The previously identified hit suddenly became unshareable!
545 // This is common for collapsed forwarding slaves but might also
546 // happen to regular hits because we are called asynchronously.
547 if (!e->mayStartHitting()) {
548 debugs(88, 3, "unshareable " << *e << ". MISS");
550 processMiss();
551 return;
552 }
553
555
556 /*
557 * Got the headers, now grok them
558 */
560
561 if (http->request->storeId().cmp(e->mem_obj->storeId()) != 0) {
562 debugs(33, DBG_IMPORTANT, "clientProcessHit: URL mismatch, '" << e->mem_obj->storeId() << "' != '" << http->request->storeId() << "'");
563 http->updateLoggingTags(LOG_TCP_MISS); // we lack a more precise LOG_*_MISS code
564 processMiss();
565 return;
566 }
567
569
570 switch (varyEvaluateMatch(e, r)) {
571
572 case VARY_NONE:
573 /* No variance detected. Continue as normal */
574 break;
575
576 case VARY_MATCH:
577 /* This is the correct entity for this request. Continue */
578 debugs(88, 2, "clientProcessHit: Vary MATCH!");
579 break;
580
581 case VARY_OTHER:
582 /* This is not the correct entity for this request. We need
583 * to requery the cache.
584 */
586 e = nullptr;
587 /* Note: varyEvalyateMatch updates the request with vary information
588 * so we only get here once. (it also takes care of cancelling loops)
589 */
590 debugs(88, 2, "clientProcessHit: Vary detected!");
592 return;
593
594 case VARY_CANCEL:
595 /* varyEvaluateMatch found a object loop. Process as miss */
596 debugs(88, DBG_IMPORTANT, "clientProcessHit: Vary object loop!");
597 http->updateLoggingTags(LOG_TCP_MISS); // we lack a more precise LOG_*_MISS code
598 processMiss();
599 return;
600 }
601
602 if (r->method == Http::METHOD_PURGE) {
603 debugs(88, 5, "PURGE gets a HIT");
605 e = nullptr;
606 purgeRequest();
607 return;
608 }
609
610 if (e->checkNegativeHit() && !r->flags.noCacheHack()) {
611 debugs(88, 5, "negative-HIT");
613 sendMoreData(result);
614 return;
615 } else if (blockedHit()) {
616 debugs(88, 5, "send_hit forces a MISS");
618 processMiss();
619 return;
620 } else if (!r->flags.internal && refreshCheckHTTP(e, r)) {
621 debugs(88, 5, "clientCacheHit: in refreshCheck() block");
622 /*
623 * We hold a stale copy; it needs to be validated
624 */
625 /*
626 * The 'needValidation' flag is used to prevent forwarding
627 * loops between siblings. If our copy of the object is stale,
628 * then we should probably only use parents for the validation
629 * request. Otherwise two siblings could generate a loop if
630 * both have a stale version of the object.
631 */
632 r->flags.needValidation = true;
633
634 if (e->lastModified() < 0) {
635 debugs(88, 3, "validate HIT object? NO. Can't calculate entry modification time. Do MISS.");
636 /*
637 * We cannot revalidate entries without knowing their
638 * modification time.
639 * XXX: BUG 1890 objects without Date do not get one added.
640 */
642 processMiss();
643 } else if (r->flags.noCache) {
644 debugs(88, 3, "validate HIT object? NO. Client sent CC:no-cache. Do CLIENT_REFRESH_MISS");
645 /*
646 * This did not match a refresh pattern that overrides no-cache
647 * we should honour the client no-cache header.
648 */
650 processMiss();
651 } else if (r->url.getScheme() == AnyP::PROTO_HTTP || r->url.getScheme() == AnyP::PROTO_HTTPS) {
652 debugs(88, 3, "validate HIT object? YES.");
653 /*
654 * Object needs to be revalidated
655 * XXX This could apply to FTP as well, if Last-Modified is known.
656 */
658 } else {
659 debugs(88, 3, "validate HIT object? NO. Client protocol non-HTTP. Do MISS.");
660 /*
661 * We don't know how to re-validate other protocols. Handle
662 * them as if the object has expired.
663 */
665 processMiss();
666 }
667 return;
668 } else if (r->conditional()) {
669 debugs(88, 5, "conditional HIT");
670 if (processConditional())
671 return;
672 }
673
674 /*
675 * plain ol' cache hit
676 */
677 debugs(88, 5, "plain old HIT");
678
679#if USE_DELAY_POOLS
680 if (e->store_status != STORE_OK)
682 else
683#endif
684 if (e->mem_status == IN_MEMORY)
686 else if (Config.onoff.offline)
688
689 sendMoreData(result);
690}
691
695void
697{
698 char *url = http->uri;
700 ErrorState *err = nullptr;
701 debugs(88, 4, r->method << ' ' << url);
702
707 if (http->storeEntry()) {
709 debugs(88, DBG_CRITICAL, "clientProcessMiss: miss on a special object (" << url << ").");
710 debugs(88, DBG_CRITICAL, "\tlog_type = " << http->loggingTags().c_str());
711 http->storeEntry()->dump(1);
712 }
713
715 }
716
718 if (r->method == Http::METHOD_PURGE) {
719 purgeRequest();
720 return;
721 }
722
724 if (r->method == Http::METHOD_OTHER) {
726 }
727
729 if (http->onlyIfCached()) {
731 return;
732 }
733
735 if (r->flags.loopDetected) {
741 return;
742 } else {
743 assert(http->out.offset == 0);
746
747 if (http->redirect.status) {
748 const HttpReplyPointer rep(new HttpReply);
754 return;
755 }
756
758
759 Comm::ConnectionPointer conn = http->getConn() != nullptr ? http->getConn()->clientConnection : nullptr;
762 }
763}
764
771void
773{
774 debugs(88, 4, http->request->method << ' ' << http->uri);
777 http->getConn(), http->request, http->al);
779 startError(err);
780}
781
783bool
785{
786 StoreEntry *const e = http->storeEntry();
787
788 const auto replyStatusCode = e->mem().baseReply().sline.status();
789 if (replyStatusCode != Http::scOkay) {
790 debugs(88, 4, "miss because " << replyStatusCode << " != 200");
792 processMiss();
793 return true;
794 }
795
796 HttpRequest &r = *http->request;
797
799 // RFC 2616: reply with 412 Precondition Failed if If-Match did not match
801 return true;
802 }
803
805 // RFC 7232: If-None-Match recipient MUST ignore IMS
806 r.flags.ims = false;
807 r.ims = -1;
808 r.imslen = 0;
810
811 if (e->hasIfNoneMatchEtag(r)) {
813 return true;
814 }
815
816 // None-Match is true (no ETag matched); treat as an unconditional hit
817 return false;
818 }
819
820 if (r.flags.ims) {
821 // handle If-Modified-Since requests from the client
822 if (e->modifiedSince(r.ims, r.imslen)) {
823 // Modified-Since is true; treat as an unconditional hit
824 return false;
825
826 } else {
827 // otherwise reply with 304 Not Modified
829 }
830 return true;
831 }
832
833 return false;
834}
835
837bool
839{
841 return false; // hits are not blocked by default
842
844 return false; // internal content "hits" cannot be blocked
845
846 const auto &rep = http->storeEntry()->mem().freshestReply();
847 {
848 std::unique_ptr<ACLFilledChecklist> chl(clientAclChecklistCreate(Config.accessList.sendHit, http));
849 chl->reply = const_cast<HttpReply*>(&rep); // ACLChecklist API bug
850 HTTPMSGLOCK(chl->reply);
851 return !chl->fastCheck().allowed(); // when in doubt, block
852 }
853}
854
855// Purges all entries with a given url
856// TODO: move to SideAgent parent, when we have one
857/*
858 * We probably cannot purge Vary-affected responses because their MD5
859 * keys depend on vary headers.
860 */
861void
862purgeEntriesByUrl(HttpRequest * req, const char *url)
863{
865 if (m.respMaybeCacheable()) {
866 const cache_key *key = storeKeyPublic(url, m);
867 debugs(88, 5, m << ' ' << url << ' ' << storeKeyText(key));
868#if USE_HTCP
870#else
871 (void)req;
872#endif
874 }
875 }
876}
877
878void
880{
881 // XXX: performance regression, c_str() reallocates
884}
885
886LogTags *
888{
889 // XXX: clientReplyContext code assumes that http cbdata is always valid.
890 // TODO: Either add cbdataReferenceValid(http) checks in all the relevant
891 // places, like this one, or remove cbdata protection of the http member.
892 return &http->al->cache.code;
893}
894
895void
897{
898 debugs(88, 3, "Config2.onoff.enable_purge = " <<
900
904 http->getConn(), http->request, http->al);
905 startError(err);
906 return;
907 }
908
909 /* Release both IP cache */
911
912 // TODO: can we use purgeAllCached() here instead?
913 purgeDoPurge();
914}
915
916void
918{
919 auto firstFound = false;
921 // special entries are only METHOD_GET entries without variance
922 if (EBIT_TEST(entry->flags, ENTRY_SPECIAL)) {
924 const auto err = clientBuildError(ERR_ACCESS_DENIED, Http::scForbidden, nullptr,
925 http->getConn(), http->request, http->al);
926 startError(err);
927 entry->abandon(__FUNCTION__);
928 return;
929 }
930 firstFound = true;
931 if (!purgeEntry(*entry, Http::METHOD_GET))
932 return;
933 }
934
936
938 if (!purgeEntry(*entry, Http::METHOD_HEAD))
939 return;
940 }
941
942 /* And for Vary, release the base URI if none of the headers was included in the request */
944 && http->request->vary_headers.find('=') != SBuf::npos) {
945 // XXX: performance regression, c_str() reallocates
947
948 if (const auto entry = storeGetPublic(tmp.c_str(), Http::METHOD_GET)) {
949 if (!purgeEntry(*entry, Http::METHOD_GET, "Vary "))
950 return;
951 }
952
953 if (const auto entry = storeGetPublic(tmp.c_str(), Http::METHOD_HEAD)) {
954 if (!purgeEntry(*entry, Http::METHOD_HEAD, "Vary "))
955 return;
956 }
957 }
958
961
962 /*
963 * Make a new entry to hold the reply to be written
964 * to the client.
965 */
966 /* TODO: This doesn't need to go through the store. Simply
967 * push down the client chain
968 */
970
972
973 const HttpReplyPointer rep(new HttpReply);
974 rep->setHeaders(purgeStatus, nullptr, nullptr, 0, 0, -1);
977}
978
979bool
980clientReplyContext::purgeEntry(StoreEntry &entry, const Http::MethodType methodType, const char *descriptionPrefix)
981{
982 debugs(88, 4, descriptionPrefix << Http::MethodStr(methodType) << " '" << entry.url() << "'" );
983#if USE_HTCP
985#endif
986 entry.release(true);
988 return true;
989}
990
991void
993{
997 http->storeEntry()->buffer();
998 const HttpReplyPointer rep(new HttpReply);
999 rep->setHeaders(Http::scOkay, nullptr, "text/plain", http->request->prefixLen(), 0, squid_curtime);
1002 http->storeEntry()->complete();
1003}
1004
1005#define SENDING_BODY 0
1006#define SENDING_HDRSONLY 1
1007int
1009{
1010 StoreEntry *entry = http->storeEntry();
1011
1012 if (entry == nullptr)
1013 return 0;
1014
1015 /*
1016 * For now, 'done_copying' is used for special cases like
1017 * Range and HEAD requests.
1018 */
1019 if (http->flags.done_copying)
1020 return 1;
1021
1023 // last-chunk was not sent
1024 return 0;
1025 }
1026
1027 /*
1028 * Handle STORE_OK objects.
1029 * objectLen(entry) will be set proprely.
1030 * RC: Does objectLen(entry) include the Headers?
1031 * RC: Yes.
1032 */
1033 if (entry->store_status == STORE_OK) {
1034 return storeOKTransferDone();
1035 } else {
1036 return storeNotOKTransferDone();
1037 }
1038}
1039
1040int
1042{
1043 assert(http->storeEntry()->objectLen() >= 0);
1044 const auto headers_sz = http->storeEntry()->mem().baseReply().hdr_sz;
1045 assert(http->storeEntry()->objectLen() >= headers_sz);
1046 const auto done = http->out.offset >= http->storeEntry()->objectLen() - headers_sz;
1047 const auto debugLevel = done ? 3 : 5;
1048 debugs(88, debugLevel, done <<
1049 " out.offset=" << http->out.offset <<
1050 " objectLen()=" << http->storeEntry()->objectLen() <<
1051 " headers_sz=" << headers_sz);
1052 return done ? 1 : 0;
1053}
1054
1055int
1057{
1058 /*
1059 * Now, handle STORE_PENDING objects
1060 */
1061 MemObject *mem = http->storeEntry()->mem_obj;
1062 assert(mem != nullptr);
1063 assert(http->request != nullptr);
1064
1066 /* haven't found end of headers yet */
1067 return 0;
1068
1069 // TODO: Use MemObject::expectedReplySize(method) after resolving XXX below.
1070 const auto expectedBodySize = mem->baseReply().content_length;
1071
1072 // XXX: The code below talks about sending data, and checks stats about
1073 // bytes written to the client connection, but this method must determine
1074 // whether we are done _receiving_ data from Store. This code should work OK
1075 // when expectedBodySize is unknown or matches written data, but it may
1076 // malfunction when we are writing ranges while receiving a full response.
1077
1078 /*
1079 * Figure out how much data we are supposed to send.
1080 * If we are sending a body and we don't have a content-length,
1081 * then we must wait for the object to become STORE_OK.
1082 */
1083 if (expectedBodySize < 0)
1084 return 0;
1085
1086 const auto done = http->out.offset >= expectedBodySize;
1087 const auto debugLevel = done ? 3 : 5;
1088 debugs(88, debugLevel, done <<
1089 " out.offset=" << http->out.offset <<
1090 " expectedBodySize=" << expectedBodySize);
1091 return done ? 1 : 0;
1092}
1093
1094/* Preconditions:
1095 * *http is a valid structure.
1096 * fd is either -1, or an open fd.
1097 *
1098 * TODO: enumify this
1099 *
1100 * This function is used by any http request sink, to determine the status
1101 * of the object.
1102 */
1105{
1106 clientReplyContext *context = dynamic_cast<clientReplyContext *>(aNode->data.getRaw());
1107 assert (context);
1108 assert (context->http == http);
1109 return context->replyStatus();
1110}
1111
1114{
1115 int done;
1116 /* Here because lower nodes don't need it */
1117
1118 if (http->storeEntry() == nullptr) {
1119 debugs(88, 5, "clientReplyStatus: no storeEntry");
1120 return STREAM_FAILED; /* yuck, but what can we do? */
1121 }
1122
1124 /* TODO: Could upstream read errors (result.flags.error) be
1125 * lost, and result in undersize requests being considered
1126 * complete. Should we tcp reset such connections ?
1127 */
1128 debugs(88, 5, "clientReplyStatus: aborted storeEntry");
1129 return STREAM_FAILED;
1130 }
1131
1132 if ((done = checkTransferDone()) != 0 || flags.complete) {
1133 debugs(88, 5, "clientReplyStatus: transfer is DONE: " << done << flags.complete);
1134 /* Ok we're finished, but how? */
1135
1137 debugs(88, 5, "clientReplyStatus: truncated response body");
1139 }
1140
1141 if (!done) {
1142 debugs(88, 5, "clientReplyStatus: closing, !done, but read 0 bytes");
1143 return STREAM_FAILED;
1144 }
1145
1146 // TODO: See also (and unify with) storeNotOKTransferDone() checks.
1147 const int64_t expectedBodySize =
1149 if (expectedBodySize >= 0 && !http->gotEnough()) {
1150 debugs(88, 5, "clientReplyStatus: client didn't get all it expected");
1152 }
1153
1154 debugs(88, 5, "clientReplyStatus: stream complete; keepalive=" <<
1156 return STREAM_COMPLETE;
1157 }
1158
1159 // XXX: Should this be checked earlier? We could return above w/o checking.
1161 debugs(88, 5, "clientReplyStatus: client reply body is too large");
1162 return STREAM_FAILED;
1163 }
1164
1165 return STREAM_NONE;
1166}
1167
1168/* Responses with no body will not have a content-type header,
1169 * which breaks the rep_mime_type acl, which
1170 * coincidentally, is the most common acl for reply access lists.
1171 * A better long term fix for this is to allow acl matches on the various
1172 * status codes, and then supply a default ruleset that puts these
1173 * codes before any user defines access entries. That way the user
1174 * can choose to block these responses where appropriate, but won't get
1175 * mysterious breakages.
1176 */
1177bool
1179{
1180 bool result;
1181
1182 switch (sline) {
1183
1184 case Http::scContinue:
1185
1187
1188 case Http::scProcessing:
1189
1190 case Http::scNoContent:
1191
1193 result = true;
1194 break;
1195
1196 default:
1197 result = false;
1198 }
1199
1200 return result;
1201}
1202
1210void
1212{
1213 HttpHeader *hdr = &reply->header;
1214 const bool is_hit = http->loggingTags().isTcpHit();
1215 HttpRequest *request = http->request;
1216
1217 if (is_hit || collapsedRevalidation == crSlave)
1219 // TODO: RFC 2965 : Must honour Cache-Control: no-cache="set-cookie2" and remove header.
1220
1221 // if there is not configured a peer proxy with login=PASS or login=PASSTHRU option enabled
1222 // remove the Proxy-Authenticate header
1223 if ( !request->peer_login || (strcmp(request->peer_login,"PASS") != 0 && strcmp(request->peer_login,"PASSTHRU") != 0)) {
1224#if USE_ADAPTATION
1225 // but allow adaptation services to authenticate clients
1226 // via request satisfaction
1228#endif
1230 }
1231
1233 // paranoid: ContentLengthInterpreter has cleaned non-generated replies
1235
1236 // if (request->range)
1237 // clientBuildRangeHeader(http, reply);
1238
1239 /*
1240 * Add a estimated Age header on cache hits.
1241 */
1242 if (is_hit) {
1243 /*
1244 * Remove any existing Age header sent by upstream caches
1245 * (note that the existing header is passed along unmodified
1246 * on cache misses)
1247 */
1249 /*
1250 * This adds the calculated object age. Note that the details of the
1251 * age calculation is performed by adjusting the timestamp in
1252 * StoreEntry::timestampsSet(), not here.
1253 */
1257 } else if (http->getConn() && http->getConn()->port->actAsOrigin) {
1258 // Swap the Date: header to current time if we are simulating an origin
1260 if (h)
1261 hdr->putExt("X-Origin-Date", h->value.termedBuf());
1265 if (h && http->storeEntry()->expires >= 0) {
1266 hdr->putExt("X-Origin-Expires", h->value.termedBuf());
1269 }
1271 // put X-Cache-Age: instead of Age:
1272 char age[64];
1273 snprintf(age, sizeof(age), "%" PRId64, static_cast<int64_t>(squid_curtime - http->storeEntry()->timestamp));
1274 hdr->putExt("X-Cache-Age", age);
1275 }
1276 } else if (http->storeEntry()->timestamp <= squid_curtime) {
1279 }
1280 }
1281
1282 /* RFC 2616: Section 14.18
1283 *
1284 * Add a Date: header if missing.
1285 * We have access to a clock therefore are required to amend any shortcoming in servers.
1286 *
1287 * NP: done after Age: to prevent ENTRY_SPECIAL double-handling this header.
1288 */
1289 if ( !hdr->has(Http::HdrType::DATE) ) {
1290 if (!http->storeEntry())
1292 else if (http->storeEntry()->timestamp > 0)
1294 else {
1295 debugs(88, DBG_IMPORTANT, "ERROR: Squid BUG #3279: HTTP reply without Date:");
1296 /* dump something useful about the problem */
1298 }
1299 }
1300
1301 /* Filter unproxyable authentication types */
1305 HttpHeaderEntry *e;
1306
1307 int connection_auth_blocked = 0;
1308 while ((e = hdr->getEntry(&pos))) {
1310 const char *value = e->value.rawBuf();
1311
1312 if ((strncasecmp(value, "NTLM", 4) == 0 &&
1313 (value[4] == '\0' || value[4] == ' '))
1314 ||
1315 (strncasecmp(value, "Negotiate", 9) == 0 &&
1316 (value[9] == '\0' || value[9] == ' '))
1317 ||
1318 (strncasecmp(value, "Kerberos", 8) == 0 &&
1319 (value[8] == '\0' || value[8] == ' '))) {
1320 if (request->flags.connectionAuthDisabled) {
1321 hdr->delAt(pos, connection_auth_blocked);
1322 continue;
1323 }
1324 request->flags.mustKeepalive = true;
1325 if (!request->flags.accelerated && !request->flags.intercepted) {
1326 httpHeaderPutStrf(hdr, Http::HdrType::PROXY_SUPPORT, "Session-Based-Authentication");
1327 /*
1328 We send "Connection: Proxy-Support" header to mark
1329 Proxy-Support as a hop-by-hop header for intermediaries that do not
1330 understand the semantics of this header. The RFC should have included
1331 this recommendation.
1332 */
1333 httpHeaderPutStrf(hdr, Http::HdrType::CONNECTION, "Proxy-support");
1334 }
1335 break;
1336 }
1337 }
1338 }
1339
1340 if (connection_auth_blocked)
1341 hdr->refreshMask();
1342 }
1343
1344#if USE_AUTH
1345 /* Handle authentication headers */
1349 ) {
1350 /* Add authentication header */
1351 /* TODO: alter errorstate to be accel on|off aware. The 0 on the next line
1352 * depends on authenticate behaviour: all schemes to date send no extra
1353 * data on 407/401 responses, and do not check the accel state on 401/407
1354 * responses
1355 */
1357 } else if (request->auth_user_request != nullptr)
1359#endif
1360
1361 SBuf cacheStatus(uniqueHostname());
1362 if (const auto hitOrFwd = http->loggingTags().cacheStatusSource())
1363 cacheStatus.append(hitOrFwd);
1364 if (firstStoreLookup_) {
1365 cacheStatus.append(";detail=");
1366 cacheStatus.append(firstStoreLookup_);
1367 }
1368 // TODO: Remove c_str() after converting HttpHeaderEntry::value to SBuf
1369 hdr->putStr(Http::HdrType::CACHE_STATUS, cacheStatus.c_str());
1370
1371 const bool maySendChunkedReply = !request->multipartRangeRequest() &&
1372 reply->sline.version.protocol == AnyP::PROTO_HTTP && // response is HTTP
1373 (request->http_ver >= Http::ProtocolVersion(1,1));
1374
1375 /* Check whether we should send keep-alive */
1376 if (!Config.onoff.error_pconns && reply->sline.status() >= 400 && !request->flags.mustKeepalive) {
1377 debugs(33, 3, "clientBuildReplyHeader: Error, don't keep-alive");
1378 request->flags.proxyKeepalive = false;
1379 } else if (!Config.onoff.client_pconns && !request->flags.mustKeepalive) {
1380 debugs(33, 2, "clientBuildReplyHeader: Connection Keep-Alive not requested by admin or client");
1381 request->flags.proxyKeepalive = false;
1382 } else if (request->flags.proxyKeepalive && shutting_down) {
1383 debugs(88, 3, "clientBuildReplyHeader: Shutting down, don't keep-alive.");
1384 request->flags.proxyKeepalive = false;
1385 } else if (request->flags.connectionAuth && !reply->keep_alive) {
1386 debugs(33, 2, "clientBuildReplyHeader: Connection oriented auth but server side non-persistent");
1387 request->flags.proxyKeepalive = false;
1388 } else if (reply->bodySize(request->method) < 0 && !maySendChunkedReply) {
1389 debugs(88, 3, "clientBuildReplyHeader: can't keep-alive, unknown body size" );
1390 request->flags.proxyKeepalive = false;
1391 } else if (fdUsageHigh()&& !request->flags.mustKeepalive) {
1392 debugs(88, 3, "clientBuildReplyHeader: Not many unused FDs, can't keep-alive");
1393 request->flags.proxyKeepalive = false;
1394 } else if (request->flags.sslBumped && !reply->persistent()) {
1395 // We do not really have to close, but we pretend we are a tunnel.
1396 debugs(88, 3, "clientBuildReplyHeader: bumped reply forces close");
1397 request->flags.proxyKeepalive = false;
1398 } else if (request->pinnedConnection() && !reply->persistent()) {
1399 // The peer wants to close the pinned connection
1400 debugs(88, 3, "pinned reply forces close");
1401 request->flags.proxyKeepalive = false;
1402 } else if (http->getConn()) {
1404 if (!Comm::IsConnOpen(conn->port->listenConn)) {
1405 // The listening port closed because of a reconfigure
1406 debugs(88, 3, "listening port closed");
1407 request->flags.proxyKeepalive = false;
1408 }
1409 }
1410
1411 // Decide if we send chunked reply
1412 if (maySendChunkedReply && reply->bodySize(request->method) < 0) {
1413 debugs(88, 3, "clientBuildReplyHeader: chunked reply");
1414 request->flags.chunkedReply = true;
1416 }
1417
1418 hdr->addVia(reply->sline.version);
1419
1420 /* Signal keep-alive or close explicitly */
1421 hdr->putStr(Http::HdrType::CONNECTION, request->flags.proxyKeepalive ? "keep-alive" : "close");
1422
1423#if ADD_X_REQUEST_URI
1424 /*
1425 * Knowing the URI of the request is useful when debugging persistent
1426 * connections in a client; we cannot guarantee the order of http headers,
1427 * but X-Request-URI is likely to be the very last header to ease use from a
1428 * debugger [hdr->entries.count-1].
1429 */
1431 http->memOjbect()->url ? http->memObject()->url : http->uri);
1432
1433#endif
1434
1435 /* Surrogate-Control requires Surrogate-Capability from upstream to pass on */
1439 }
1440 /* TODO: else case: drop any controls intended specifically for our surrogate ID */
1441 }
1442
1443 httpHdrMangleList(hdr, request, http->al, ROR_REPLY);
1444}
1445
1446void
1448{
1449 assert(reply == nullptr);
1450
1453
1454 http->al->reply = reply;
1455
1457 /* RFC 2616 requires us to advertise our version (but only on real HTTP traffic) */
1459 }
1460
1461 /* do header conversions */
1463}
1464
1468void
1470{
1471 StoreEntry *e = http->storeEntry();
1472 assert(e); // or we are not dealing with a hit
1473 // We probably have not locked the entry earlier, unfortunately. We lock it
1474 // now so that we can unlock two lines later (and trigger cleanup).
1475 // Ideally, ClientHttpRequest::storeEntry() should lock/unlock, but it is
1476 // used so inconsistently that simply adding locking there leads to bugs.
1477 e->lock("clientReplyContext::forgetHit");
1478 http->storeEntry(nullptr);
1479 e->unlock("clientReplyContext::forgetHit"); // may delete e
1480}
1481
1482void
1484{
1485 HttpRequest *r = http->request;
1486
1487 // client sent CC:no-cache or some other condition has been
1488 // encountered which prevents delivering a public/cached object.
1489 // XXX: The above text does not match the condition below. It might describe
1490 // the opposite condition, but the condition itself should be adjusted
1491 // (e.g., to honor flags.noCache in cache manager requests).
1492 if (!r->flags.noCache || r->flags.internal) {
1493 const auto e = storeGetPublicByRequest(r);
1495 } else {
1496 // "external" no-cache requests skip Store lookups
1497 identifyFoundObject(nullptr, "no-cache");
1498 }
1499}
1500
1505void
1507{
1508 detailStoreLookup(detail);
1509
1510 HttpRequest *r = http->request;
1511 http->storeEntry(newEntry);
1512 const auto e = http->storeEntry();
1513
1514 /* Release IP-cache entries on reload */
1518 if (r->flags.noCache || r->flags.noCacheHack())
1520
1521 if (!e) {
1523 debugs(85, 3, "StoreEntry is NULL - MISS");
1525 doGetMoreData();
1526 return;
1527 }
1528
1529 if (Config.onoff.offline) {
1531 debugs(85, 3, "offline HIT " << *e);
1533 doGetMoreData();
1534 return;
1535 }
1536
1537 if (http->redirect.status) {
1539 debugs(85, 3, "REDIRECT status forced StoreEntry to NULL (no body on 3XX responses) " << *e);
1540 forgetHit();
1542 doGetMoreData();
1543 return;
1544 }
1545
1546 if (!e->validToSend()) {
1547 debugs(85, 3, "!storeEntryValidToSend MISS " << *e);
1548 forgetHit();
1550 doGetMoreData();
1551 return;
1552 }
1553
1554 if (EBIT_TEST(e->flags, ENTRY_SPECIAL)) {
1555 /* \li Special entries are always hits, no matter what the client says */
1556 debugs(85, 3, "ENTRY_SPECIAL HIT " << *e);
1558 doGetMoreData();
1559 return;
1560 }
1561
1562 if (r->flags.noCache) {
1563 debugs(85, 3, "no-cache REFRESH MISS " << *e);
1564 forgetHit();
1566 doGetMoreData();
1567 return;
1568 }
1569
1570 if (e->hittingRequiresCollapsing() && !startCollapsingOn(*e, false)) {
1571 debugs(85, 3, "prohibited CF MISS " << *e);
1572 forgetHit();
1574 doGetMoreData();
1575 return;
1576 }
1577
1578 debugs(85, 3, "default HIT " << *e);
1580 doGetMoreData();
1581}
1582
1584void
1586{
1587 if (!firstStoreLookup_) {
1588 debugs(85, 7, detail);
1589 firstStoreLookup_ = detail;
1590 } else {
1591 debugs(85, 7, "ignores " << detail << " after " << firstStoreLookup_);
1592 }
1593}
1594
1604void
1606{
1607 /* Test preconditions */
1608 assert(aNode != nullptr);
1610 assert(aNode->node.prev == nullptr);
1611 assert(aNode->node.next != nullptr);
1612 clientReplyContext *context = dynamic_cast<clientReplyContext *>(aNode->data.getRaw());
1613 assert (context);
1614 assert(context->http == http);
1615
1616 if (!context->ourNode)
1617 context->ourNode = aNode;
1618
1619 /* no cbdatareference, this is only used once, and safely */
1620 if (context->flags.storelogiccomplete) {
1621 context->requestMoreBodyFromStore();
1622 return;
1623 }
1624
1625 if (context->http->request->method == Http::METHOD_PURGE) {
1626 context->purgeRequest();
1627 return;
1628 }
1629
1630 // OPTIONS with Max-Forwards:0 handled in clientProcessRequest()
1631
1632 if (context->http->request->method == Http::METHOD_TRACE) {
1634 context->traceReply();
1635 return;
1636 }
1637
1638 /* continue forwarding, not finished yet. */
1640
1641 context->doGetMoreData();
1642 } else
1643 context->identifyStoreObject();
1644}
1645
1646void
1648{
1649 /* We still have to do store logic processing - vary, cache hit etc */
1650 if (http->storeEntry() != nullptr) {
1651 /* someone found the object in the cache for us */
1652 StoreIOBuffer localTempBuffer;
1653
1654 http->storeEntry()->lock("clientReplyContext::doGetMoreData");
1655
1657
1659#if USE_DELAY_POOLS
1661#endif
1662
1664 /* guarantee nothing has been sent yet! */
1665 assert(http->out.size == 0);
1666 assert(http->out.offset == 0);
1667
1668 if (ConnStateData *conn = http->getConn()) {
1669 if (Ip::Qos::TheConfig.isHitTosActive()) {
1670 Ip::Qos::doTosLocalHit(conn->clientConnection);
1671 }
1672
1673 if (Ip::Qos::TheConfig.isHitNfmarkActive()) {
1674 Ip::Qos::doNfmarkLocalHit(conn->clientConnection);
1675 }
1676 }
1677
1679 } else {
1680 /* MISS CASE, http->loggingTags() are already set! */
1681 processMiss();
1682 }
1683}
1684
1686void
1688{
1690 clientStreamDetach(node, http);
1691}
1692
1697void
1699{
1700 clientReplyContext *context = static_cast<clientReplyContext *>(data);
1701 context->sendMoreData (result);
1702}
1703
1704void
1706{
1707 /* At least, I think that's what this does */
1710}
1711
1712bool
1714{
1715 return /* aborted request */
1717 /* Upstream read error */ (result.flags.error);
1718}
1719
1720void
1722{
1728 debugs(88, 5, "A stream error has occurred, marking as complete and sending no data.");
1729 StoreIOBuffer localTempBuffer;
1730 flags.complete = 1;
1731 http->request->flags.streamError = true;
1732 localTempBuffer.flags.error = result.flags.error;
1734 localTempBuffer);
1735}
1736
1737void
1739{
1740 if (result.length == 0) {
1741 debugs(88, 5, "clientReplyContext::pushStreamData: marking request as complete due to 0 length store result");
1742 flags.complete = 1;
1743 }
1744
1745 assert(!result.length || result.offset == next()->readBuffer.offset);
1747 result);
1748}
1749
1752{
1754 return getNextNode();
1755}
1756
1757void
1759{
1762 http->getConn(), http->request, http->al);
1765 startError(err);
1766
1767}
1768
1770void
1772{
1774 ErrorState *const err =
1776 nullptr, http->getConn(), http->request, http->al);
1779 startError(err);
1780}
1781
1783void
1785{
1786 StoreEntry *e = http->storeEntry();
1787 const time_t timestamp = e->timestamp;
1788 const auto temprep = e->mem().freshestReply().make304();
1789 // log as TCP_INM_HIT if code 304 generated for
1790 // If-None-Match request
1791 if (!http->request->flags.ims)
1793 else
1797 e = http->storeEntry();
1798 // Copy timestamp from the original entry so the 304
1799 // reply has a meaningful Age: header.
1800 e->timestampsSet();
1801 e->timestamp = timestamp;
1802 e->replaceHttpReply(temprep);
1803 e->complete();
1804 /*
1805 * TODO: why put this in the store and then serialise it and
1806 * then parse it again. Simply mark the request complete in
1807 * our context and write the reply struct to the client side.
1808 */
1810}
1811
1814void
1816{
1820 else
1822}
1823
1824void
1826{
1827 /* NP: this should probably soft-fail to a zero-sized-reply error ?? */
1828 assert(reply);
1829
1835 return;
1836 }
1837
1841 return;
1842 }
1843
1845 if (!Config.accessList.reply) {
1847 return;
1848 }
1849
1851 ACLFilledChecklist *replyChecklist =
1853 replyChecklist->reply = reply;
1854 HTTPMSGLOCK(replyChecklist->reply);
1855 replyChecklist->nonBlockingCheck(ProcessReplyAccessResult, this);
1856}
1857
1858void
1860{
1861 clientReplyContext *me = static_cast<clientReplyContext *>(voidMe);
1863}
1864
1865void
1867{
1868 debugs(88, 2, "The reply for " << http->request->method
1869 << ' ' << http->uri << " is " << accessAllowed << ", because it matched "
1870 << (AclMatchedName ? AclMatchedName : "NO ACL's"));
1871
1872 if (!accessAllowed.allowed()) {
1873 ErrorState *err;
1874 err_type page_id;
1876
1878
1879 if (page_id == ERR_NONE)
1880 page_id = ERR_ACCESS_DENIED;
1881
1882 err = clientBuildError(page_id, Http::scForbidden, nullptr,
1883 http->getConn(), http->request, http->al);
1884
1886
1888
1889 startError(err);
1890
1891 return;
1892 }
1893
1894 /* Ok, the reply is allowed, */
1896
1899 auto body_size = lastStreamBufferedBytes.length; // may be zero
1900
1901 debugs(88, 3, "clientReplyContext::sendMoreData: Appending " <<
1902 (int) body_size << " bytes after " << reply->hdr_sz <<
1903 " bytes of headers");
1904
1905#if USE_SQUID_ESI
1906
1910 debugs(88, 2, "Enabling ESI processing for " << http->uri);
1913 }
1914
1915#endif
1916
1918 /* do not forward body for HEAD replies */
1919 body_size = 0;
1920 http->flags.done_copying = true;
1921 flags.complete = 1;
1922 }
1923
1925 flags.headersSent = true;
1926
1927 // next()->readBuffer.offset may be positive for Range requests, but our
1928 // localTempBuffer initialization code assumes that next()->readBuffer.data
1929 // points to the response body at offset 0 because the first
1930 // storeClientCopy() request always has offset 0 (i.e. our first Store
1931 // request ignores next()->readBuffer.offset).
1932 //
1933 // XXX: We cannot fully check that assumption: readBuffer.offset field is
1934 // often out of sync with the buffer content, and if some buggy code updates
1935 // the buffer while we were waiting for the processReplyAccessResult()
1936 // callback, we may not notice.
1937
1938 StoreIOBuffer localTempBuffer;
1939 const auto body_buf = next()->readBuffer.data;
1940
1941 //Server side may disable ranges under some circumstances.
1942
1943 if ((!http->request->range))
1944 next()->readBuffer.offset = 0;
1945
1946 if (next()->readBuffer.offset > 0) {
1947 if (Less(body_size, next()->readBuffer.offset)) {
1948 /* Can't use any of the body we received. send nothing */
1949 localTempBuffer.length = 0;
1950 localTempBuffer.data = nullptr;
1951 } else {
1952 localTempBuffer.length = body_size - next()->readBuffer.offset;
1953 localTempBuffer.data = body_buf + next()->readBuffer.offset;
1954 }
1955 } else {
1956 localTempBuffer.length = body_size;
1957 localTempBuffer.data = body_buf;
1958 }
1959
1961 http, reply, localTempBuffer);
1962
1963 return;
1964}
1965
1966void
1968{
1969 if (deleting)
1970 return;
1971
1972 debugs(88, 5, http->uri << " got " << result);
1973
1974 StoreEntry *entry = http->storeEntry();
1975
1976 if (ConnStateData * conn = http->getConn()) {
1977 if (!conn->isOpen()) {
1978 debugs(33,3, "not sending more data to closing connection " << conn->clientConnection);
1979 return;
1980 }
1981 if (conn->pinning.zeroReply) {
1982 debugs(33,3, "not sending more data after a pinned zero reply " << conn->clientConnection);
1983 return;
1984 }
1985
1986 if (!flags.headersSent && !http->loggingTags().isTcpHit()) {
1987 // We get here twice if processReplyAccessResult() calls startError().
1988 // TODO: Revise when we check/change QoS markings to reduce syscalls.
1989 if (Ip::Qos::TheConfig.isHitTosActive()) {
1990 Ip::Qos::doTosLocalMiss(conn->clientConnection, http->request->hier.code);
1991 }
1992 if (Ip::Qos::TheConfig.isHitNfmarkActive()) {
1993 Ip::Qos::doNfmarkLocalMiss(conn->clientConnection, http->request->hier.code);
1994 }
1995 }
1996
1997 debugs(88, 5, conn->clientConnection <<
1998 " '" << entry->url() << "'" <<
1999 " out.offset=" << http->out.offset);
2000 }
2001
2002 /* We've got the final data to start pushing... */
2004
2005 assert(http->request != nullptr);
2006
2007 /* ESI TODO: remove this assert once everything is stable */
2010
2011 makeThisHead();
2012
2013 if (errorInStream(result)) {
2014 sendStreamError(result);
2015 return;
2016 }
2017
2018 if (!matchesStreamBodyBuffer(result)) {
2019 // Subsequent processing expects response body bytes to be at the start
2020 // of our Client Stream buffer. When given something else (e.g., bytes
2021 // in our tempbuf), we copy and adjust to meet those expectations.
2022 const auto &ourClientStreamsBuffer = next()->readBuffer;
2023 assert(result.length <= ourClientStreamsBuffer.length);
2024 memcpy(ourClientStreamsBuffer.data, result.data, result.length);
2025 result.data = ourClientStreamsBuffer.data;
2026 }
2027
2029
2030 if (flags.headersSent) {
2031 pushStreamData(result);
2032 return;
2033 }
2034
2035 cloneReply();
2036
2037#if USE_DELAY_POOLS
2038 if (sc)
2040#endif
2041
2043 return;
2044}
2045
2048bool
2050{
2051 // the answer is undefined for errors; they are not really "body buffers"
2052 Assure(!their.flags.error);
2053
2054 if (!their.length)
2055 return true; // an empty body area always matches our body area
2056
2057 if (their.data != next()->readBuffer.data) {
2058 debugs(88, 7, "no: " << their << " vs. " << next()->readBuffer);
2059 return false;
2060 }
2061
2062 return true;
2063}
2064
2065void
2067{
2069 lastStreamBufferedBytes = result; // may be unchanged and/or zero-length
2070}
2071
2072void
2074{
2075 clientAclChecklistFill(checklist, http);
2076}
2077
2078/* Using this breaks the client layering just a little!
2079 */
2080void
2082{
2083 assert(http != nullptr);
2084 /*
2085 * For erroneous requests, we might not have a h->request,
2086 * so make a fake one.
2087 */
2088
2089 if (http->request == nullptr) {
2090 const auto connManager = http->getConn();
2091 const auto mx = MasterXaction::MakePortful(connManager ? connManager->port : nullptr);
2092 // XXX: These fake URI parameters shadow the real (or error:...) URI.
2093 // TODO: Either always set the request earlier and assert here OR use
2094 // http->uri (converted to Anyp::Uri) to create this catch-all request.
2095 const_cast<HttpRequest *&>(http->request) = new HttpRequest(m, AnyP::PROTO_NONE, "http", null_string, mx);
2097 }
2098
2099 StoreEntry *e = storeCreateEntry(storeId(), http->log_uri, reqFlags, m);
2100
2101 // Make entry collapsible ASAP, to increase collapsing chances for others,
2102 // TODO: every must-revalidate and similar request MUST reach the origin,
2103 // but do we have to prohibit others from collapsing on that request?
2104 if (reqFlags.cachable &&
2105 !reqFlags.needValidation &&
2106 (m == Http::METHOD_GET || m == Http::METHOD_HEAD) &&
2108 // make the entry available for future requests now
2109 (void)Store::Root().allowCollapsing(e, reqFlags, m);
2110 }
2111
2112 sc = storeClientListAdd(e, this);
2113
2114#if USE_DELAY_POOLS
2116#endif
2117
2118 /* The next line is illegal because we don't know if the client stream
2119 * buffers have been set up
2120 */
2121 // storeClientCopy(http->sc, e, 0, HTTP_REQBUF_SZ, http->reqbuf,
2122 // SendMoreData, this);
2123 /* So, we mark the store logic as complete */
2125
2126 /* and get the caller to request a read, from wherever they are */
2127 /* NOTE: after ANY data flows down the pipe, even one step,
2128 * this function CAN NOT be used to manage errors
2129 */
2130 http->storeEntry(e);
2131}
2132
2133ErrorState *
2134clientBuildError(err_type page_id, Http::StatusCode status, char const *url,
2135 const ConnStateData *conn, HttpRequest *request, const AccessLogEntry::Pointer &al)
2136{
2137 const auto err = new ErrorState(page_id, status, request, al);
2138 err->src_addr = conn && conn->clientConnection ? conn->clientConnection->remote : Ip::Address::NoAddr();
2139
2140 if (url)
2141 err->url = xstrdup(url);
2142
2143 return err;
2144}
2145
#define Assure(condition)
Definition: Assure.h:35
int esiEnableProcessing(HttpReply *rep)
Definition: Esi.cc:2239
CSCB esiProcessStream
CSR esiStreamRead
CSD esiStreamDetach
CSS esiStreamStatus
void httpHeaderPutStrf(HttpHeader *hdr, Http::HdrType id, const char *fmt,...)
void httpHdrMangleList(HttpHeader *l, HttpRequest *request, const AccessLogEntryPointer &al, req_or_rep_t req_or_rep)
@ ROR_REPLY
ssize_t HttpHeaderPos
Definition: HttpHeader.h:45
#define HttpHeaderInitPos
Definition: HttpHeader.h:48
@ LOG_TCP_REFRESH_FAIL_ERR
Definition: LogTags.h:43
@ LOG_TCP_DENIED
Definition: LogTags.h:52
@ LOG_TCP_REFRESH
Definition: LogTags.h:45
@ LOG_TCP_NEGATIVE_HIT
Definition: LogTags.h:50
@ LOG_TCP_REFRESH_MODIFIED
Definition: LogTags.h:44
@ LOG_TCP_REDIRECT
Definition: LogTags.h:55
@ LOG_TCP_OFFLINE_HIT
Definition: LogTags.h:54
@ LOG_TCP_HIT
Definition: LogTags.h:39
@ LOG_TCP_REFRESH_FAIL_OLD
Definition: LogTags.h:42
@ LOG_TCP_MISS
Definition: LogTags.h:40
@ LOG_TCP_MEM_HIT
Definition: LogTags.h:51
@ LOG_TCP_IMS_HIT
Definition: LogTags.h:47
@ LOG_TCP_REFRESH_UNMODIFIED
Definition: LogTags.h:41
@ LOG_TCP_DENIED_REPLY
Definition: LogTags.h:53
@ LOG_TCP_SWAPFAIL_MISS
Definition: LogTags.h:49
@ LOG_TCP_CLIENT_REFRESH_MISS
Definition: LogTags.h:46
@ LOG_TCP_INM_HIT
Definition: LogTags.h:48
time_t squid_curtime
Definition: stub_libtime.cc:20
class SquidConfig Config
Definition: SquidConfig.cc:12
class SquidConfig2 Config2
Definition: SquidConfig.cc:14
constexpr bool Less(const A a, const B b)
whether integer a is less than integer b, with correct overflow handling
Definition: SquidMath.h:48
void(void *, StoreIOBuffer) STCB
Definition: StoreClient.h:32
int storeClientIsThisAClient(store_client *sc, void *someClient)
#define Must(condition)
Definition: TextException.h:75
int conn
the current server connection FD
Definition: Transport.cc:26
#define assert(EX)
Definition: assert.h:17
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:265
#define cbdataReferenceDone(var)
Definition: cbdata.h:352
#define cbdataReference(var)
Definition: cbdata.h:343
#define CBDATA_CLASS_INIT(type)
Definition: cbdata.h:320
void nonBlockingCheck(ACLCB *callback, void *callback_data)
Definition: Checklist.cc:237
HttpReplyPointer reply
class AccessLogEntry::CacheDetails cache
class AccessLogEntry::HttpDetails http
bool allowed() const
Definition: Acl.h:156
ProtocolType protocol
which protocol this version is for
AnyP::UriScheme const & getScheme() const
Definition: Uri.h:67
void host(const char *src)
Definition: Uri.cc:100
static void AddReplyAuthHeader(HttpReply *rep, UserRequest::Pointer auth_user_request, HttpRequest *request, int accelerated, int internal)
Add the appropriate [Proxy-]Authenticate header to the given reply.
Definition: UserRequest.cc:479
struct ClientHttpRequest::Out out
HttpRequest *const request
ConnStateData * getConn() const
void updateLoggingTags(const LogTags_ot code)
update the code in the transaction processing tags
MemObject * memObject() const
struct ClientHttpRequest::Flags flags
bool requestSatisfactionMode() const
StoreEntry * storeEntry() const
const LogTags & loggingTags() const
the processing tags associated with this request transaction.
const AccessLogEntry::Pointer al
access.log entry
StoreEntry * loggingEntry() const
struct ClientHttpRequest::Redirect redirect
AnyP::Port port
destination port of the request that caused serverConnection
Definition: client_side.h:145
static DelayId DelayClient(ClientHttpRequest *, HttpReply *reply=nullptr)
Definition: DelayId.cc:68
Definition: ETag.h:18
int weak
true if it is a weak validator
Definition: ETag.h:21
const char * str
quoted-string
Definition: ETag.h:20
void * callback_data
Definition: errorpage.h:186
Http::StatusCode httpStatus
Definition: errorpage.h:173
static void Start(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
Initiates request forwarding to a peer or origin server.
Definition: FwdState.cc:341
Http::HdrType id
Definition: HttpHeader.h:66
void removeHopByHopEntries()
Definition: HttpHeader.cc:1711
void putStr(Http::HdrType id, const char *str)
Definition: HttpHeader.cc:996
void delAt(HttpHeaderPos pos, int &headers_deleted)
Definition: HttpHeader.cc:695
void putInt(Http::HdrType id, int number)
Definition: HttpHeader.cc:969
int delById(Http::HdrType id)
Definition: HttpHeader.cc:667
void refreshMask()
Definition: HttpHeader.cc:723
HttpHeaderEntry * getEntry(HttpHeaderPos *pos) const
Definition: HttpHeader.cc:584
void addVia(const AnyP::ProtocolVersion &ver, const HttpHeader *from=nullptr)
Definition: HttpHeader.cc:946
int has(Http::HdrType id) const
Definition: HttpHeader.cc:938
int64_t getInt64(Http::HdrType id) const
Definition: HttpHeader.cc:1134
HttpHeaderEntry * findEntry(Http::HdrType id) const
Definition: HttpHeader.cc:603
void putExt(const char *name, const char *value)
Definition: HttpHeader.cc:1076
void putTime(Http::HdrType id, time_t htime)
Definition: HttpHeader.cc:987
Http::StatusLine sline
Definition: HttpReply.h:56
HttpReplyPointer make304() const
Definition: HttpReply.cc:129
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
Definition: HttpReply.cc:170
int64_t bodySize(const HttpRequestMethod &) const
Definition: HttpReply.cc:377
void removeIrrelevantContentLength()
Some response status codes prohibit sending Content-Length (RFC 7230 section 3.3.2).
Definition: HttpReply.cc:648
bool receivedBodyTooLarge(HttpRequest &, int64_t receivedBodySize)
Definition: HttpReply.cc:557
void redirect(Http::StatusCode, const char *)
Definition: HttpReply.cc:205
bool expectedBodyTooLarge(HttpRequest &request)
Definition: HttpReply.cc:565
HttpReply * clone() const override
Definition: HttpReply.cc:613
short int keep_alive
Definition: HttpReply.h:53
bool conditional() const
has at least one recognized If-* header
Definition: HttpRequest.cc:572
HttpHdrRange * range
Definition: HttpRequest.h:143
CbcPointer< ConnStateData > clientConnectionManager
Definition: HttpRequest.h:232
HttpRequestMethod method
Definition: HttpRequest.h:114
int prefixLen() const
Definition: HttpRequest.cc:369
bool multipartRangeRequest() const
Definition: HttpRequest.cc:434
HierarchyLogEntry hier
Definition: HttpRequest.h:157
time_t ims
Definition: HttpRequest.h:145
time_t lastmod
Definition: HttpRequest.h:167
RequestFlags flags
Definition: HttpRequest.h:141
SBuf vary_headers
The variant second-stage cache key. Generated from Vary header pattern for this request.
Definition: HttpRequest.h:170
String etag
A strong etag of the cached entry. Used for refreshing that entry.
Definition: HttpRequest.h:191
ConnStateData * pinnedConnection()
Definition: HttpRequest.cc:725
void ignoreRange(const char *reason)
forgets about the cached Range header (for a reason)
Definition: HttpRequest.cc:621
char * peer_login
Definition: HttpRequest.h:163
const SBuf storeId()
Definition: HttpRequest.cc:733
void swapOut(StoreEntry *e)
Definition: HttpRequest.cc:334
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
AnyP::Uri url
the request URI
Definition: HttpRequest.h:115
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:744
bool persistent() const
Definition: Message.cc:236
HttpHeader header
Definition: Message.h:74
int hdr_sz
Definition: Message.h:81
ParseState pstate
the current parsing state
Definition: Message.h:94
int64_t content_length
Definition: Message.h:83
AnyP::ProtocolVersion http_ver
Definition: Message.h:72
AnyP::ProtocolVersion version
breakdown of protocol version label: (HTTP/ICY) and (0.9/1.0/1.1)
Definition: StatusLine.h:65
Http::StatusCode status() const
retrieve the status code for this status line
Definition: StatusLine.h:45
static const Address & NoAddr()
Definition: Address.h:302
bool ignored
_IGNORED: the response was not used for anything
Definition: LogTags.h:24
const char * c_str() const
compute the status access.log field
Definition: LogTags.cc:66
const char * cacheStatusSource() const
Definition: LogTags.cc:115
LogTagsErrors err
various problems augmenting the primary log tag
Definition: LogTags.h:84
LogTags_ot oldType
a set of client protocol, cache use, and other transaction outcome tags
Definition: LogTags.h:93
bool isTcpHit() const
determine if the log tag code indicates a cache HIT
Definition: LogTags.cc:101
static Pointer MakePortful(const AnyP::PortCfgPointer &aPort)
Definition: MasterXaction.h:54
const HttpReply & freshestReply() const
Definition: MemObject.h:68
const char * storeId() const
Definition: MemObject.cc:53
const HttpReply & baseReply() const
Definition: MemObject.h:60
C * getRaw() const
Definition: RefCount.h:89
bool needValidation
Definition: RequestFlags.h:50
bool accelerated
Definition: RequestFlags.h:62
bool connectionAuth
Definition: RequestFlags.h:85
bool chunkedReply
Definition: RequestFlags.h:99
bool noCacheHack() const
Definition: RequestFlags.h:133
bool mustKeepalive
Definition: RequestFlags.h:83
bool intercepted
Definition: RequestFlags.h:66
bool proxyKeepalive
Definition: RequestFlags.h:42
bool failOnValidationError
Definition: RequestFlags.h:52
bool loopDetected
Definition: RequestFlags.h:40
bool connectionAuthDisabled
Definition: RequestFlags.h:87
SupportOrVeto cachable
whether the response may be stored in the cache
Definition: RequestFlags.h:35
Definition: SBuf.h:94
static const size_type npos
Definition: SBuf.h:99
const char * c_str()
Definition: SBuf.cc:516
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
Definition: SBuf.h:275
size_type find(char c, size_type startPos=0) const
Definition: SBuf.cc:584
bool isEmpty() const
Definition: SBuf.h:431
SBuf & append(const SBuf &S)
Definition: SBuf.cc:185
Comm::ConnectionPointer clientConnection
Definition: Server.h:100
struct SquidConfig2::@120 onoff
int error_pconns
Definition: SquidConfig.h:306
struct SquidConfig::@107 accessList
acl_access * reply
Definition: SquidConfig.h:379
struct SquidConfig::@106 onoff
AclDenyInfoList * denyInfoList
Definition: SquidConfig.h:408
int client_pconns
Definition: SquidConfig.h:304
int collapsed_forwarding
Definition: SquidConfig.h:323
acl_access * sendHit
Definition: SquidConfig.h:367
bool mayInitiateCollapsing() const
whether Squid configuration allows us to become a CF initiator
Definition: StoreClient.h:58
bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const
Definition: store_client.cc:66
mem_status_t mem_status
Definition: Store.h:240
uint16_t flags
Definition: Store.h:232
MemObject & mem()
Definition: Store.h:51
bool hasIfMatchEtag(const HttpRequest &request) const
has ETag matching at least one of the If-Match etags
Definition: store.cc:1859
void ensureMemObject(const char *storeId, const char *logUri, const HttpRequestMethod &aMethod)
initialize mem_obj (if needed) and set URIs/method (if missing)
Definition: store.cc:1575
bool hasIfNoneMatchEtag(const HttpRequest &request) const
has ETag matching at least one of the If-None-Match etags
Definition: store.cc:1866
void dump(int debug_lvl) const
Definition: store.cc:1485
int unlock(const char *context)
Definition: store.cc:455
const char * url() const
Definition: store.cc:1552
void complete()
Definition: store.cc:1017
time_t expires
Definition: Store.h:226
bool hasEtag(ETag &etag) const
whether this entry has an ETag; if yes, puts ETag value into parameter
Definition: store.cc:1848
void lastModified(const time_t when)
Definition: Store.h:176
void release(const bool shareable=false)
Definition: store.cc:1132
void lock(const char *context)
Definition: store.cc:431
time_t timestamp
Definition: Store.h:224
bool timestampsSet()
Definition: store.cc:1373
void clearPublicKeyScope()
Definition: store.cc:595
void storeErrorResponse(HttpReply *reply)
Store a prepared error response. MemObject locks the reply object.
Definition: store.cc:1674
bool mayStartHitting() const
Definition: Store.h:288
int checkNegativeHit() const
Definition: store.cc:1286
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
Definition: store.cc:1691
MemObject * mem_obj
Definition: Store.h:221
bool modifiedSince(const time_t ims, const int imslen=-1) const
Definition: store.cc:1822
int64_t objectLen() const
Definition: Store.h:257
store_status_t store_status
Definition: Store.h:244
void buffer() override
Definition: store.cc:1587
void releaseRequest(const bool shareable=false)
Definition: store.cc:444
unsigned error
Definition: StoreIOBuffer.h:55
int64_t offset
Definition: StoreIOBuffer.h:58
struct StoreIOBuffer::@141 flags
bool allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &)
tries to make the entry available for collapsing future requests
Definition: Controller.cc:735
static bool SmpAware()
whether there are any SMP-aware storages
Definition: Controller.cc:920
void evictIfFound(const cache_key *) override
Definition: Controller.cc:501
void clean()
Definition: String.cc:103
char const * rawBuf() const
Definition: SquidString.h:86
char const * termedBuf() const
Definition: SquidString.h:92
void handleIMSReply(StoreIOBuffer result)
clientStreamNode * ourNode
void sendNotModifiedOrPreconditionFailedError()
void setReplyToReply(HttpReply *reply)
creates a store entry for the reply and appends error reply to it
static ACLCB ProcessReplyAccessResult
bool alwaysAllowResponse(Http::StatusCode sline) const
static STCB HandleIMSReply
void sendPreconditionFailedError()
send 412 (Precondition Failed) to client
store_client * old_sc
void triggerInitialStoreRead(STCB=SendMoreData)
void cacheHit(StoreIOBuffer result)
bool matchesStreamBodyBuffer(const StoreIOBuffer &) const
void sendStreamError(StoreIOBuffer const &result)
@ crInitiator
we initiated collapsed revalidation request
@ crNone
collapsed revalidation is not allowed for this context
@ crSlave
we collapsed on the existing revalidation request
void pushStreamData(const StoreIOBuffer &)
void sendClientUpstreamResponse(const StoreIOBuffer &upstreamResponse)
Http::StatusCode purgeStatus
void startError(ErrorState *err)
void identifyFoundObject(StoreEntry *entry, const char *detail)
void sendNotModified()
send 304 (Not Modified) to client
void createStoreEntry(const HttpRequestMethod &m, RequestFlags flags)
void setReplyToStoreEntry(StoreEntry *e, const char *reason)
replaces current response store entry with the given one
bool errorInStream(const StoreIOBuffer &result) const
bool blockedHit() const
whether squid.conf send_hit prevents us from serving this hit
static decltype(::storeClientCopy) storeClientCopy
int storeNotOKTransferDone() const
void removeClientStoreReference(store_client **scp, ClientHttpRequest *http)
friend CSR clientGetMoreData
~clientReplyContext() override
struct clientReplyContext::Flags flags
void processReplyAccessResult(const Acl::Answer &accessAllowed)
const char * firstStoreLookup_
CollapsedRevalidation collapsedRevalidation
char tempbuf[HTTP_REQBUF_SZ]
const char * storeLookupString(bool found) const
bool purgeEntry(StoreEntry &, const Http::MethodType, const char *descriptionPrefix="")
clientStreamNode * next() const
void noteStreamBufferredBytes(const StoreIOBuffer &)
void sendMoreData(StoreIOBuffer result)
ClientHttpRequest * http
StoreIOBuffer lastStreamBufferedBytes
HTTP response body bytes stored in our Client Stream buffer (if any)
clientStream_status_t replyStatus()
void removeStoreReference(store_client **scp, StoreEntry **ep)
LogTags * loggingTags() const override
const char * storeId() const
bool processConditional()
process conditional request from client
int storeOKTransferDone() const
clientStreamNode * getNextNode() const
void fillChecklist(ACLFilledChecklist &) const override
configure the given checklist (to reflect the current transaction state)
void setReplyToError(err_type, Http::StatusCode, char const *, const ConnStateData *, HttpRequest *, const char *, Auth::UserRequest::Pointer)
builds error using clientBuildError() and calls setReplyToError() below
void purgeDoPurge()
releases both cached GET and HEAD entries
static STCB SendMoreData
clientReplyContext(ClientHttpRequest *)
void detailStoreLookup(const char *detail)
remembers the very first Store lookup classification, ignoring the rest
StoreIOBuffer readBuffer
Definition: clientStream.h:94
ClientStreamData data
Definition: clientStream.h:93
dlink_node node
Definition: clientStream.h:87
void setDelayId(DelayId delay_id)
void CSD(clientStreamNode *, ClientHttpRequest *)
client stream detach
void CSR(clientStreamNode *, ClientHttpRequest *)
client stream read
clientStream_status_t CSS(clientStreamNode *, ClientHttpRequest *)
int varyEvaluateMatch(StoreEntry *entry, HttpRequest *request)
void clientAclChecklistFill(ACLFilledChecklist &checklist, ClientHttpRequest *http)
ACLFilledChecklist * clientAclChecklistCreate(const acl_access *acl, ClientHttpRequest *http)
CSS clientReplyStatus
ErrorState * clientBuildError(err_type, Http::StatusCode, char const *, const ConnStateData *, HttpRequest *, const AccessLogEntry::Pointer &)
SQUIDCEXTERN CSR clientGetMoreData
void purgeEntriesByUrl(HttpRequest *req, const char *url)
SQUIDCEXTERN CSD clientReplyDetach
#define DBG_IMPORTANT
Definition: Stream.h:38
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:194
#define DBG_CRITICAL
Definition: Stream.h:37
#define EBIT_TEST(flag, bit)
Definition: defines.h:69
@ IN_MEMORY
Definition: enums.h:36
@ HTCP_CLR_INVALIDATION
Definition: enums.h:242
@ HTCP_CLR_PURGE
Definition: enums.h:241
@ VARY_OTHER
Definition: enums.h:195
@ VARY_NONE
Definition: enums.h:193
@ VARY_CANCEL
Definition: enums.h:196
@ VARY_MATCH
Definition: enums.h:194
clientStream_status_t
Definition: enums.h:125
@ STREAM_COMPLETE
Definition: enums.h:127
@ STREAM_UNPLANNED_COMPLETE
Definition: enums.h:132
@ STREAM_NONE
Definition: enums.h:126
@ STREAM_FAILED
Definition: enums.h:137
@ ENTRY_BAD_LENGTH
Definition: enums.h:114
@ ENTRY_SPECIAL
Definition: enums.h:84
@ ENTRY_ABORTED
Definition: enums.h:115
@ STORE_OK
Definition: enums.h:50
err_type
Definition: forward.h:14
@ ERR_ACCESS_DENIED
Definition: forward.h:18
@ ERR_NONE
Definition: forward.h:15
@ ERR_PRECONDITION_FAILED
Definition: forward.h:47
@ ERR_TOO_BIG
Definition: forward.h:40
@ ERR_ONLY_IF_CACHED_MISS
Definition: forward.h:39
int fdUsageHigh(void)
Definition: fd.cc:271
int shutting_down
const char * null_string
err_type aclGetDenyInfoPage(AclDenyInfoList **head, const char *name, int redirect_allowed)
Definition: Gadgets.cc:39
const char * AclMatchedName
Definition: Acl.cc:29
@ ACCESS_ALLOWED
Definition: Acl.h:116
void clientStreamCallback(clientStreamNode *thisObject, ClientHttpRequest *http, HttpReply *rep, StoreIOBuffer replyBuffer)
void clientStreamInsertHead(dlink_list *list, CSR *func, CSCB *callback, CSD *detach, CSS *status, ClientStreamData data)
void clientStreamDetach(clientStreamNode *thisObject, ClientHttpRequest *http)
void errorAppendEntry(StoreEntry *entry, ErrorState *err)
Definition: errorpage.cc:717
void ipcacheInvalidateNegative(const char *name)
Definition: ipcache.cc:881
void ipcacheInvalidate(const char *name)
Definition: ipcache.cc:864
void HTTPMSGUNLOCK(M *&a)
Definition: Message.h:150
void HTTPMSGLOCK(Http::Message *a)
Definition: Message.h:161
#define HTTP_REQBUF_SZ
Definition: forward.h:14
@ PROTO_NONE
Definition: ProtocolType.h:24
@ PROTO_HTTPS
Definition: ProtocolType.h:27
@ PROTO_HTTP
Definition: ProtocolType.h:25
bool IsConnOpen(const Comm::ConnectionPointer &conn)
Definition: Connection.cc:27
Definition: forward.h:18
enum Http::_method_t MethodType
StatusCode
Definition: StatusCode.h:20
@ scProcessing
Definition: StatusCode.h:24
@ scGatewayTimeout
Definition: StatusCode.h:75
@ scForbidden
Definition: StatusCode.h:47
@ scUnauthorized
Definition: StatusCode.h:45
@ scNotImplemented
Definition: StatusCode.h:72
@ scInternalServerError
Definition: StatusCode.h:71
@ scNotFound
Definition: StatusCode.h:48
@ scProxyAuthenticationRequired
Definition: StatusCode.h:51
@ scNone
Definition: StatusCode.h:21
@ scNotModified
Definition: StatusCode.h:40
@ scOkay
Definition: StatusCode.h:26
@ scContinue
Definition: StatusCode.h:22
@ scNoContent
Definition: StatusCode.h:30
@ scSwitchingProtocols
Definition: StatusCode.h:23
@ scPreconditionFailed
Definition: StatusCode.h:56
const SBuf & MethodStr(const MethodType m)
Definition: MethodType.h:100
@ METHOD_TRACE
Definition: MethodType.h:30
@ METHOD_NONE
Definition: MethodType.h:22
@ METHOD_OTHER
Definition: MethodType.h:93
@ METHOD_ENUM_END
Definition: MethodType.h:94
@ METHOD_GET
Definition: MethodType.h:25
@ METHOD_PURGE
Definition: MethodType.h:92
@ METHOD_HEAD
Definition: MethodType.h:28
@ SURROGATE_CONTROL
@ WWW_AUTHENTICATE
@ IF_MODIFIED_SINCE
@ TRANSFER_ENCODING
@ SURROGATE_CAPABILITY
@ PROXY_AUTHENTICATE
AnyP::ProtocolVersion ProtocolVersion(unsigned int aMajor, unsigned int aMinor)
HTTP version label information.
int doNfmarkLocalHit(const Comm::ConnectionPointer &conn)
Definition: QosConfig.cc:275
Config TheConfig
Globally available instance of Qos::Config.
Definition: QosConfig.cc:283
int doTosLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode)
Definition: QosConfig.cc:226
int doNfmarkLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode)
Definition: QosConfig.cc:247
int doTosLocalHit(const Comm::ConnectionPointer &conn)
Definition: QosConfig.cc:268
Controller & Root()
safely access controller singleton
Definition: Controller.cc:938
#define xstrdup
void neighborsHtcpClear(StoreEntry *e, HttpRequest *req, const HttpRequestMethod &method, htcp_clr_reason reason)
Definition: neighbors.cc:1673
int refreshCheckHTTP(const StoreEntry *entry, HttpRequest *request)
Definition: refresh.cc:575
static int sc[16]
Definition: smbdes.c:121
#define SQUIDCEXTERN
Definition: squid.h:21
unsigned char cache_key
Store key.
Definition: forward.h:29
StoreEntry * storeGetPublicByRequestMethod(HttpRequest *req, const HttpRequestMethod &method, const KeyScope keyScope)
Definition: store.cc:496
StoreEntry * storeGetPublicByRequest(HttpRequest *req, const KeyScope keyScope)
Definition: store.cc:502
StoreEntry * storeCreateEntry(const char *url, const char *logUrl, const RequestFlags &flags, const HttpRequestMethod &method)
Definition: store.cc:745
StoreEntry * storeGetPublic(const char *uri, const HttpRequestMethod &method)
Definition: store.cc:490
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
store_client * storeClientListAdd(StoreEntry *e, void *data)
const cache_key * storeKeyPublic(const char *url, const HttpRequestMethod &method, const KeyScope keyScope)
const char * storeKeyText(const cache_key *key)
@ ksRevalidation
Definition: store_key_md5.h:20
uint64_t size
Response header and body bytes written to the client connection.
unsigned complete
we have read all we can from upstream
Definition: parse.c:104
const char * uniqueHostname(void)
Definition: tools.cc:547
#define PRId64
Definition: types.h:104

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors