Squid Web Cache master
Loading...
Searching...
No Matches
client_side_reply.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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 "clientStream.h"
17#include "errorpage.h"
18#include "ETag.h"
19#include "fd.h"
20#include "fde.h"
21#include "format/Token.h"
22#include "FwdState.h"
23#include "globals.h"
24#include "HeaderMangling.h"
25#include "http/Stream.h"
26#include "HttpHeaderTools.h"
27#include "HttpReply.h"
28#include "HttpRequest.h"
29#include "ip/QosConfig.h"
30#include "ipcache.h"
31#include "log/access_log.h"
32#include "MemObject.h"
33#include "mime_header.h"
34#include "neighbors.h"
35#include "refresh.h"
36#include "RequestFlags.h"
37#include "SquidConfig.h"
38#include "SquidMath.h"
39#include "Store.h"
40#include "StrList.h"
41#include "tools.h"
42#if USE_AUTH
43#include "auth/UserRequest.h"
44#endif
45#if USE_DELAY_POOLS
46#include "DelayPools.h"
47#endif
48
49#include <memory>
50
52
53/* Local functions */
56
57/* privates */
58
60{
61 deleting = true;
62 /* This may trigger a callback back into SendMoreData as the cbdata
63 * is still valid
64 */
66 /* old_entry might still be set if we didn't yet get the reply
67 * code in HandleIMSReply() */
71}
72
74 purgeStatus(Http::scNone),
75 http(cbdataReference(clientContext)),
76 sc(nullptr),
77 ourNode(nullptr),
78 reply(nullptr),
79 old_entry(nullptr),
80 old_sc(nullptr),
81 old_lastmod(-1),
82 deleting(false),
83 collapsedRevalidation(crNone)
84{
85 *tempbuf = 0;
86}
87
93void
95 err_type err, Http::StatusCode status, char const *uri,
96 const ConnStateData *conn, HttpRequest *failedrequest, const char *,
97#if USE_AUTH
98 Auth::UserRequest::Pointer auth_user_request
99#else
100 void*
101#endif
102)
103{
104 auto errstate = clientBuildError(err, status, uri, conn, failedrequest, http->al);
105
106#if USE_AUTH
107 errstate->auth_user_request = auth_user_request;
108#endif
109 setReplyToError(failedrequest ? failedrequest->method : HttpRequestMethod(Http::METHOD_NONE), errstate);
110}
111
113{
114 if (errstate->httpStatus == Http::scNotImplemented && http->request)
115 /* prevent confusion over whether we default to persistent or not */
117
118 http->al->http.code = errstate->httpStatus;
119
120 if (http->request)
121 http->request->ignoreRange("responding with a Squid-generated error");
122
124 assert(errstate->callback_data == nullptr);
125 errorAppendEntry(http->storeEntry(), errstate);
126 /* Now the caller reads to get this */
127}
128
129void
131{
132 Must(futureReply);
133 http->al->http.code = futureReply->sline.status();
134
135 HttpRequestMethod method;
136 if (http->request) { // nil on responses to unparsable requests
137 http->request->ignoreRange("responding with a Squid-generated reply");
138 method = http->request->method;
139 }
140
142
143 http->storeEntry()->storeErrorResponse(futureReply);
144 /* Now the caller reads to get futureReply */
145}
146
147// Assumes that the entry contains an error response without Content-Range.
148// To use with regular entries, make HTTP Range header removal conditional.
150{
151 entry->lock("clientReplyContext::setReplyToStoreEntry"); // removeClientStoreReference() unlocks
152 sc = storeClientListAdd(entry, this);
153#if USE_DELAY_POOLS
155#endif
156 if (http->request)
157 http->request->ignoreRange(reason);
159 http->storeEntry(entry);
160}
161
162void
164 StoreEntry ** ep)
165{
166 StoreEntry *e;
167 store_client *sc_tmp = *scp;
168
169 if ((e = *ep) != nullptr) {
170 *ep = nullptr;
171 storeUnregister(sc_tmp, e, this);
172 *scp = nullptr;
173 e->unlock("clientReplyContext::removeStoreReference");
174 }
175}
176
177void
179{
180 StoreEntry *reference = aHttpRequest->storeEntry();
181 removeStoreReference(scp, &reference);
182 aHttpRequest->storeEntry(reference);
183}
184
185void
187{
188 assert(old_sc == nullptr);
189 debugs(88, 3, "clientReplyContext::saveState: saving store context");
191 old_sc = sc;
194 /* Prevent accessing the now saved entries */
195 http->storeEntry(nullptr);
196 sc = nullptr;
197}
198
199void
201{
202 assert(old_sc != nullptr);
203 debugs(88, 3, "clientReplyContext::restoreState: Restoring store context");
206 sc = old_sc;
209 /* Prevent accessed the old saved entries */
210 old_entry = nullptr;
211 old_sc = nullptr;
212 old_lastmod = -1;
213 old_etag.clean();
214}
215
216void
223
229
233void
235{
236 Assure(recipient != HandleIMSReply);
237 lastStreamBufferedBytes = StoreIOBuffer(); // storeClientCopy(next()->readBuffer) invalidates
238 StoreIOBuffer localTempBuffer (next()->readBuffer.length, 0, next()->readBuffer.data);
239 ::storeClientCopy(sc, http->storeEntry(), localTempBuffer, recipient, this);
240}
241
246void
248{
249 lastStreamBufferedBytes = StoreIOBuffer(); // storeClientCopy(next()->readBuffer) invalidates
250 ::storeClientCopy(sc, http->storeEntry(), next()->readBuffer, SendMoreData, this);
251}
252
253/* there is an expired entry in the store.
254 * setup a temporary buffer area and perform an IMS to the origin
255 */
256void
258{
259 const char *url = storeId();
260 debugs(88, 3, "clientReplyContext::processExpired: '" << http->uri << "'");
261 const time_t lastmod = http->storeEntry()->lastModified();
262 assert(lastmod >= 0);
263 /*
264 * check if we are allowed to contact other servers
265 * @?@: Instead of a 504 (Gateway Timeout) reply, we may want to return
266 * a stale entry *if* it matches client requirements
267 */
268
269 if (http->onlyIfCached()) {
271 return;
272 }
273
275 http->request->flags.refresh = true;
276#if STORE_CLIENT_LIST_DEBUG
277 /* Prevent a race with the store client memory free routines
278 */
280#endif
281 /* Prepare to make a new temporary request */
282 saveState();
283
284 // TODO: Consider also allowing regular (non-collapsed) revalidation hits.
285 // TODO: support collapsed revalidation for Vary-controlled entries
286 bool collapsingAllowed = Config.onoff.collapsed_forwarding &&
289
290 StoreEntry *entry = nullptr;
291 if (collapsingAllowed) {
292 if (const auto e = storeGetPublicByRequest(http->request, ksRevalidation)) {
293 if (e->hittingRequiresCollapsing() && startCollapsingOn(*e, true)) {
294 entry = e;
295 entry->lock("clientReplyContext::processExpired#alreadyRevalidating");
296 } else {
297 e->abandon(__func__);
298 // assume mayInitiateCollapsing() would fail too
299 collapsingAllowed = false;
300 }
301 }
302 }
303
304 if (entry) {
306 debugs(88, 5, "collapsed on existing revalidation entry: " << *entry);
308 } else {
309 entry = storeCreateEntry(url,
311 /* NOTE, don't call StoreEntry->lock(), storeCreateEntry() does it */
312
313 if (collapsingAllowed && mayInitiateCollapsing() &&
314 Store::Root().allowCollapsing(entry, http->request->flags, http->request->method)) {
315 debugs(88, 5, "allow other revalidation requests to collapse on " << *entry);
317 } else {
319 }
320 }
321
322 sc = storeClientListAdd(entry, this);
323#if USE_DELAY_POOLS
324 /* delay_id is already set on original store client */
326#endif
327
328 http->request->lastmod = lastmod;
329
331 ETag etag = {nullptr, -1}; // TODO: make that a default ETag constructor
332 if (old_entry->hasEtag(etag) && !etag.weak)
333 http->request->etag = etag.str;
334 }
335
336 debugs(88, 5, "lastmod " << entry->lastModified());
337 http->storeEntry(entry);
338 assert(http->out.offset == 0);
340
342 /*
343 * A refcounted pointer so that FwdState stays around as long as
344 * this clientReplyContext does
345 */
346 Comm::ConnectionPointer conn = http->getConn() != nullptr ? http->getConn()->clientConnection : nullptr;
348 }
349 /* Register with storage manager to receive updates when data comes in. */
350
351 if (EBIT_TEST(entry->flags, ENTRY_ABORTED))
352 debugs(88, DBG_CRITICAL, "clientReplyContext::processExpired: Found ENTRY_ABORTED object");
353
354 {
355 /* start counting the length from 0 */
356 StoreIOBuffer localTempBuffer(HTTP_REQBUF_SZ, 0, tempbuf);
357 // keep lastStreamBufferedBytes: tempbuf is not a Client Stream buffer
358 ::storeClientCopy(sc, entry, localTempBuffer, HandleIMSReply, this);
359 }
360}
361
362void
364{
366
369
370 /* here the data to send is the data we just received */
372 sendMoreData(upstreamResponse);
373}
374
375void
377{
378 clientReplyContext *context = (clientReplyContext *)data;
379 context->handleIMSReply(result);
380}
381
382void
384{
385 /* Get the old request back */
386 restoreState();
387
389 debugs(88, 3, "stale entry aborted while we revalidated: " << *http->storeEntry());
391 processMiss();
392 return;
393 }
394
395 /* here the data to send is in the next nodes buffers already */
399}
400
401/* This is the workhorse of the HandleIMSReply callback.
402 *
403 * It is called when we've got data back from the origin following our
404 * IMS request to revalidate a stale entry.
405 */
406void
408{
409 if (deleting)
410 return;
411
412 if (http->storeEntry() == nullptr)
413 return;
414
415 debugs(88, 3, http->storeEntry()->url() << " got " << result);
416
418 return;
419
421 debugs(88, 3, "CF slave hit private non-shareable " << *http->storeEntry() << ". MISS");
422 // restore context to meet processMiss() expectations
423 restoreState();
425 processMiss();
426 return;
427 }
428
429 // request to origin was aborted
431 debugs(88, 3, "request to origin aborted '" << http->storeEntry()->url() << "', sending old entry to client");
434 return;
435 }
436
437 const auto oldStatus = old_entry->mem().freshestReply().sline.status();
438 const auto &new_rep = http->storeEntry()->mem().freshestReply();
439 const auto status = new_rep.sline.status();
440
441 // XXX: Disregard stale incomplete (i.e. still being written) borrowed (i.e.
442 // not caused by our request) IMS responses. That new_rep may be very old!
443
444 // origin replied 304
445 if (status == Http::scNotModified) {
446 // TODO: The update may not be instantaneous. Should we wait for its
447 // completion to avoid spawning too much client-disassociated work?
448 if (!Store::Root().updateOnNotModified(old_entry, *http->storeEntry())) {
449 old_entry->release(true);
450 restoreState();
452 processMiss();
453 return;
454 }
455
457 http->request->flags.staleIfHit = false; // old_entry is no longer stale
458
459 // if client sent IMS
461 // forward the 304 from origin
462 debugs(88, 3, "origin replied 304, revalidated existing entry and forwarding 304 to client");
464 return;
465 }
466
467 // send existing entry, it's still valid
468 debugs(88, 3, "origin replied 304, revalidated existing entry and sending " << oldStatus << " to client");
470 return;
471 }
472
473 // origin replied with a non-error code
474 if (status > Http::scNone && status < Http::scInternalServerError) {
475 // RFC 9111 section 4:
476 // "When more than one suitable response is stored,
477 // a cache MUST use the most recent one
478 // (as determined by the Date header field)."
479 if (new_rep.olderThan(&old_entry->mem().freshestReply())) {
480 http->al->cache.code.err.ignored = true;
481 debugs(88, 3, "origin replied " << status << " but with an older date header, sending old entry (" << oldStatus << ") to client");
483 return;
484 }
485
487 debugs(88, 3, "origin replied " << status << ", forwarding to client");
489 return;
490 }
491
492 // origin replied with an error
495 debugs(88, 3, "origin replied with error " << status << ", forwarding to client due to fail_on_validation_err");
497 return;
498 }
499
500 // ignore and let client have old entry
502 debugs(88, 3, "origin replied with error " << status << ", sending old entry (" << oldStatus << ") to client");
504}
505
508
510void
512{
513 clientReplyContext *context = (clientReplyContext *)data;
514 context->cacheHit(result);
515}
516
520void
522{
524 if (deleting) {
525 debugs(88, 3, "HIT object being deleted. Ignore the HIT.");
526 return;
527 }
528
529 StoreEntry *e = http->storeEntry();
530
532
533 debugs(88, 3, http->uri << " got " << result);
534
535 if (http->storeEntry() == nullptr) {
536 debugs(88, 3, "clientCacheHit: request aborted");
537 return;
538 } else if (result.flags.error) {
539 /* swap in failure */
540 debugs(88, 3, "clientCacheHit: swapin failure for " << http->uri);
543 processMiss();
544 return;
545 }
546
547 // The previously identified hit suddenly became unshareable!
548 // This is common for collapsed forwarding slaves but might also
549 // happen to regular hits because we are called asynchronously.
550 if (!e->mayStartHitting()) {
551 debugs(88, 3, "unshareable " << *e << ". MISS");
553 processMiss();
554 return;
555 }
556
557 if (EBIT_TEST(e->flags, ENTRY_ABORTED)) {
558 debugs(88, 3, "refusing aborted " << *e);
560 processMiss();
561 return;
562 }
563
564 /*
565 * Got the headers, now grok them
566 */
568
569 if (http->request->storeId().cmp(e->mem_obj->storeId()) != 0) {
570 debugs(33, DBG_IMPORTANT, "clientProcessHit: URL mismatch, '" << e->mem_obj->storeId() << "' != '" << http->request->storeId() << "'");
571 http->updateLoggingTags(LOG_TCP_MISS); // we lack a more precise LOG_*_MISS code
572 processMiss();
573 return;
574 }
575
577
578 switch (varyEvaluateMatch(e, r)) {
579
580 case VARY_NONE:
581 /* No variance detected. Continue as normal */
582 break;
583
584 case VARY_MATCH:
585 /* This is the correct entity for this request. Continue */
586 debugs(88, 2, "clientProcessHit: Vary MATCH!");
587 break;
588
589 case VARY_OTHER:
590 /* This is not the correct entity for this request. We need
591 * to requery the cache.
592 */
594 e = nullptr;
595 /* Note: varyEvalyateMatch updates the request with vary information
596 * so we only get here once. (it also takes care of cancelling loops)
597 */
598 debugs(88, 2, "clientProcessHit: Vary detected!");
600 return;
601
602 case VARY_CANCEL:
603 /* varyEvaluateMatch found a object loop. Process as miss */
604 debugs(88, DBG_IMPORTANT, "clientProcessHit: Vary object loop!");
605 http->updateLoggingTags(LOG_TCP_MISS); // we lack a more precise LOG_*_MISS code
606 processMiss();
607 return;
608 }
609
610 if (r->method == Http::METHOD_PURGE) {
611 debugs(88, 5, "PURGE gets a HIT");
613 e = nullptr;
614 purgeRequest();
615 return;
616 }
617
618 if (e->checkNegativeHit() && !r->flags.noCacheHack()) {
619 debugs(88, 5, "negative-HIT");
621 sendMoreData(result);
622 return;
623 } else if (blockedHit()) {
624 debugs(88, 5, "send_hit forces a MISS");
626 processMiss();
627 return;
628 } else if (!r->flags.internal && !didCollapse && refreshCheckHTTP(e, r)) {
629 debugs(88, 5, "clientCacheHit: in refreshCheck() block");
630 /*
631 * We hold a stale copy; it needs to be validated
632 */
633 /*
634 * The 'needValidation' flag is used to prevent forwarding
635 * loops between siblings. If our copy of the object is stale,
636 * then we should probably only use parents for the validation
637 * request. Otherwise two siblings could generate a loop if
638 * both have a stale version of the object.
639 */
640 r->flags.needValidation = true;
641
642 if (e->lastModified() < 0) {
643 debugs(88, 3, "validate HIT object? NO. Can't calculate entry modification time. Do MISS.");
644 /*
645 * We cannot revalidate entries without knowing their
646 * modification time.
647 * XXX: BUG 1890 objects without Date do not get one added.
648 */
650 processMiss();
651 } else if (r->flags.noCache) {
652 debugs(88, 3, "validate HIT object? NO. Client sent CC:no-cache. Do CLIENT_REFRESH_MISS");
653 /*
654 * This did not match a refresh pattern that overrides no-cache
655 * we should honour the client no-cache header.
656 */
658 processMiss();
659 } else if (r->url.getScheme() == AnyP::PROTO_HTTP || r->url.getScheme() == AnyP::PROTO_HTTPS) {
660 debugs(88, 3, "validate HIT object? YES.");
661 /*
662 * Object needs to be revalidated
663 * XXX This could apply to FTP as well, if Last-Modified is known.
664 */
666 } else {
667 debugs(88, 3, "validate HIT object? NO. Client protocol non-HTTP. Do MISS.");
668 /*
669 * We don't know how to re-validate other protocols. Handle
670 * them as if the object has expired.
671 */
673 processMiss();
674 }
675 return;
676 } else if (r->conditional()) {
677 debugs(88, 5, "conditional HIT");
678 if (processConditional())
679 return;
680 }
681
682 /*
683 * plain ol' cache hit
684 */
685 debugs(88, 5, "plain old HIT");
686
687#if USE_DELAY_POOLS
688 if (e->store_status != STORE_OK)
690 else
691#endif
692 if (e->mem_status == IN_MEMORY)
694 else if (Config.onoff.offline)
696
697 sendMoreData(result);
698}
699
703void
705{
706 char *url = http->uri;
708 ErrorState *err = nullptr;
709 debugs(88, 4, r->method << ' ' << url);
710
715 if (http->storeEntry()) {
717 debugs(88, DBG_CRITICAL, "clientProcessMiss: miss on a special object (" << url << ").");
718 debugs(88, DBG_CRITICAL, "\tlog_type = " << http->loggingTags().c_str());
719 http->storeEntry()->dump(1);
720 }
721
723 }
724
726 if (r->method == Http::METHOD_PURGE) {
727 purgeRequest();
728 return;
729 }
730
732 if (r->method == Http::METHOD_OTHER) {
734 }
735
737 if (http->onlyIfCached()) {
739 return;
740 }
741
743 if (r->flags.loopDetected) {
749 return;
750 } else {
751 assert(http->out.offset == 0);
754
755 if (http->redirect.status) {
756 const HttpReplyPointer rep(new HttpReply);
762 return;
763 }
764
766
767 Comm::ConnectionPointer conn = http->getConn() != nullptr ? http->getConn()->clientConnection : nullptr;
769 FwdState::Start(conn, http->storeEntry(), r, http->al);
770 }
771}
772
779void
789
791bool
793{
794 StoreEntry *const e = http->storeEntry();
795
796 const auto replyStatusCode = e->mem().baseReply().sline.status();
797 if (replyStatusCode != Http::scOkay) {
798 debugs(88, 4, "miss because " << replyStatusCode << " != 200");
800 processMiss();
801 return true;
802 }
803
804 HttpRequest &r = *http->request;
805
807 // RFC 2616: reply with 412 Precondition Failed if If-Match did not match
809 return true;
810 }
811
813 // RFC 7232: If-None-Match recipient MUST ignore IMS
814 r.flags.ims = false;
815 r.ims = -1;
816 r.imslen = 0;
818
819 if (e->hasIfNoneMatchEtag(r)) {
821 return true;
822 }
823
824 // None-Match is true (no ETag matched); treat as an unconditional hit
825 return false;
826 }
827
828 if (r.flags.ims) {
829 // handle If-Modified-Since requests from the client
830 if (e->modifiedSince(r.ims, r.imslen)) {
831 // Modified-Since is true; treat as an unconditional hit
832 return false;
833
834 } else {
835 // otherwise reply with 304 Not Modified
837 }
838 return true;
839 }
840
841 return false;
842}
843
845bool
847{
849 return false; // hits are not blocked by default
850
852 return false; // internal content "hits" cannot be blocked
853
854 {
858 return !chl.fastCheck().allowed(); // when in doubt, block
859 }
860}
861
862// Purges all entries with a given url
863// TODO: move to SideAgent parent, when we have one
864/*
865 * We probably cannot purge Vary-affected responses because their MD5
866 * keys depend on vary headers.
867 */
868void
869purgeEntriesByUrl(HttpRequest * req, const char *url)
870{
872 if (m.respMaybeCacheable()) {
873 const cache_key *key = storeKeyPublic(url, m);
874 debugs(88, 5, m << ' ' << url << ' ' << storeKeyText(key));
875#if USE_HTCP
877#else
878 (void)req;
879#endif
881 }
882 }
883}
884
885void
887{
888 // XXX: performance regression, c_str() reallocates
891}
892
893LogTags *
895{
896 // XXX: clientReplyContext code assumes that http cbdata is always valid.
897 // TODO: Either add cbdataReferenceValid(http) checks in all the relevant
898 // places, like this one, or remove cbdata protection of the http member.
899 return &http->al->cache.code;
900}
901
902void
904{
905 debugs(88, 3, "Config2.onoff.enable_purge = " <<
907
911 http->getConn(), http->request, http->al);
912 startError(err);
913 return;
914 }
915
916 /* Release both IP cache */
918
919 // TODO: can we use purgeAllCached() here instead?
920 purgeDoPurge();
921}
922
923void
925{
926 auto firstFound = false;
928 // special entries are only METHOD_GET entries without variance
929 if (EBIT_TEST(entry->flags, ENTRY_SPECIAL)) {
931 const auto err = clientBuildError(ERR_ACCESS_DENIED, Http::scForbidden, nullptr,
932 http->getConn(), http->request, http->al);
933 startError(err);
934 entry->abandon(__func__);
935 return;
936 }
937 firstFound = true;
938 if (!purgeEntry(*entry, Http::METHOD_GET))
939 return;
940 }
941
943
945 if (!purgeEntry(*entry, Http::METHOD_HEAD))
946 return;
947 }
948
949 /* And for Vary, release the base URI if none of the headers was included in the request */
951 && http->request->vary_headers.find('=') != SBuf::npos) {
952 // XXX: performance regression, c_str() reallocates
954
955 if (const auto entry = storeGetPublic(tmp.c_str(), Http::METHOD_GET)) {
956 if (!purgeEntry(*entry, Http::METHOD_GET, "Vary "))
957 return;
958 }
959
960 if (const auto entry = storeGetPublic(tmp.c_str(), Http::METHOD_HEAD)) {
961 if (!purgeEntry(*entry, Http::METHOD_HEAD, "Vary "))
962 return;
963 }
964 }
965
968
969 /*
970 * Make a new entry to hold the reply to be written
971 * to the client.
972 */
973 /* TODO: This doesn't need to go through the store. Simply
974 * push down the client chain
975 */
977
979
980 const HttpReplyPointer rep(new HttpReply);
981 rep->setHeaders(purgeStatus, nullptr, nullptr, 0, 0, -1);
984}
985
986bool
987clientReplyContext::purgeEntry(StoreEntry &entry, const Http::MethodType methodType, const char *descriptionPrefix)
988{
989 debugs(88, 4, descriptionPrefix << Http::MethodStr(methodType) << " '" << entry.url() << "'" );
990#if USE_HTCP
992#endif
993 entry.release(true);
995 return true;
996}
997
998void
1000{
1004 http->storeEntry()->buffer();
1005 MemBuf content;
1006 content.init();
1007 http->request->pack(&content, true /* hide authorization data */);
1008 const HttpReplyPointer rep(new HttpReply);
1009 rep->setHeaders(Http::scOkay, nullptr, "message/http", content.contentSize(), 0, squid_curtime);
1010 rep->body.set(SBuf(content.buf, content.size));
1012 http->storeEntry()->completeSuccessfully("traceReply() stored the entire response");
1013}
1014
1015#define SENDING_BODY 0
1016#define SENDING_HDRSONLY 1
1017int
1019{
1020 StoreEntry *entry = http->storeEntry();
1021
1022 if (entry == nullptr)
1023 return 0;
1024
1025 /*
1026 * For now, 'done_copying' is used for special cases like
1027 * Range and HEAD requests.
1028 */
1029 if (http->flags.done_copying)
1030 return 1;
1031
1033 // last-chunk was not sent
1034 return 0;
1035 }
1036
1037 /*
1038 * Handle STORE_OK objects.
1039 * objectLen(entry) will be set properly.
1040 * RC: Does objectLen(entry) include the Headers?
1041 * RC: Yes.
1042 */
1043 if (entry->store_status == STORE_OK) {
1044 return storeOKTransferDone();
1045 } else {
1046 return storeNotOKTransferDone();
1047 }
1048}
1049
1050int
1052{
1053 assert(http->storeEntry()->objectLen() >= 0);
1054 const auto headers_sz = http->storeEntry()->mem().baseReply().hdr_sz;
1055 assert(http->storeEntry()->objectLen() >= headers_sz);
1056 const auto done = http->out.offset >= http->storeEntry()->objectLen() - headers_sz;
1057 const auto debugLevel = done ? 3 : 5;
1058 debugs(88, debugLevel, done <<
1059 " out.offset=" << http->out.offset <<
1060 " objectLen()=" << http->storeEntry()->objectLen() <<
1061 " headers_sz=" << headers_sz);
1062 return done ? 1 : 0;
1063}
1064
1065int
1067{
1068 /*
1069 * Now, handle STORE_PENDING objects
1070 */
1071 MemObject *mem = http->storeEntry()->mem_obj;
1072 assert(mem != nullptr);
1073 assert(http->request != nullptr);
1074
1076 /* haven't found end of headers yet */
1077 return 0;
1078
1079 // TODO: Use MemObject::expectedReplySize(method) after resolving XXX below.
1080 const auto expectedBodySize = mem->baseReply().content_length;
1081
1082 // XXX: The code below talks about sending data, and checks stats about
1083 // bytes written to the client connection, but this method must determine
1084 // whether we are done _receiving_ data from Store. This code should work OK
1085 // when expectedBodySize is unknown or matches written data, but it may
1086 // malfunction when we are writing ranges while receiving a full response.
1087
1088 /*
1089 * Figure out how much data we are supposed to send.
1090 * If we are sending a body and we don't have a content-length,
1091 * then we must wait for the object to become STORE_OK.
1092 */
1093 if (expectedBodySize < 0)
1094 return 0;
1095
1096 const auto done = http->out.offset >= expectedBodySize;
1097 const auto debugLevel = done ? 3 : 5;
1098 debugs(88, debugLevel, done <<
1099 " out.offset=" << http->out.offset <<
1100 " expectedBodySize=" << expectedBodySize);
1101 return done ? 1 : 0;
1102}
1103
1104/* Preconditions:
1105 * *http is a valid structure.
1106 * fd is either -1, or an open fd.
1107 *
1108 * TODO: enumify this
1109 *
1110 * This function is used by any http request sink, to determine the status
1111 * of the object.
1112 */
1115{
1116 clientReplyContext *context = dynamic_cast<clientReplyContext *>(aNode->data.getRaw());
1117 assert (context);
1118 assert (context->http == http);
1119 return context->replyStatus();
1120}
1121
1124{
1125 int done;
1126 /* Here because lower nodes don't need it */
1127
1128 if (http->storeEntry() == nullptr) {
1129 debugs(88, 5, "clientReplyStatus: no storeEntry");
1130 return STREAM_FAILED; /* yuck, but what can we do? */
1131 }
1132
1134 /* TODO: Could upstream read errors (result.flags.error) be
1135 * lost, and result in undersize requests being considered
1136 * complete. Should we tcp reset such connections ?
1137 */
1138 debugs(88, 5, "clientReplyStatus: aborted storeEntry");
1139 return STREAM_FAILED;
1140 }
1141
1142 if ((done = checkTransferDone()) != 0 || flags.complete) {
1143 debugs(88, 5, "clientReplyStatus: transfer is DONE: " << done << flags.complete);
1144 /* Ok we're finished, but how? */
1145
1147 debugs(88, 5, "clientReplyStatus: truncated response body");
1149 }
1150
1151 if (!done) {
1152 debugs(88, 5, "clientReplyStatus: closing, !done, but read 0 bytes");
1153 return STREAM_FAILED;
1154 }
1155
1156 // TODO: See also (and unify with) storeNotOKTransferDone() checks.
1157 const int64_t expectedBodySize =
1159 if (expectedBodySize >= 0 && !http->gotEnough()) {
1160 debugs(88, 5, "clientReplyStatus: client didn't get all it expected");
1162 }
1163
1164 debugs(88, 5, "clientReplyStatus: stream complete; keepalive=" <<
1166 return STREAM_COMPLETE;
1167 }
1168
1169 // XXX: Should this be checked earlier? We could return above w/o checking.
1171 debugs(88, 5, "clientReplyStatus: client reply body is too large");
1172 return STREAM_FAILED;
1173 }
1174
1175 return STREAM_NONE;
1176}
1177
1178/* Responses with no body will not have a content-type header,
1179 * which breaks the rep_mime_type acl, which
1180 * coincidentally, is the most common acl for reply access lists.
1181 * A better long term fix for this is to allow acl matches on the various
1182 * status codes, and then supply a default ruleset that puts these
1183 * codes before any user defines access entries. That way the user
1184 * can choose to block these responses where appropriate, but won't get
1185 * mysterious breakages.
1186 */
1187bool
1189{
1190 bool result;
1191
1192 switch (sline) {
1193
1194 case Http::scContinue:
1195
1197
1198 case Http::scProcessing:
1199
1200 case Http::scNoContent:
1201
1203 result = true;
1204 break;
1205
1206 default:
1207 result = false;
1208 }
1209
1210 return result;
1211}
1212
1220void
1222{
1223 HttpHeader *hdr = &reply->header;
1224 const bool is_hit = http->loggingTags().isTcpHit();
1225 HttpRequest *request = http->request;
1226
1227 if (is_hit || collapsedRevalidation == crSlave)
1229 // TODO: RFC 2965 : Must honour Cache-Control: no-cache="set-cookie2" and remove header.
1230
1231 // if there is not configured a peer proxy with login=PASS or login=PASSTHRU option enabled
1232 // remove the Proxy-Authenticate header
1233 if ( !request->peer_login || (strcmp(request->peer_login,"PASS") != 0 && strcmp(request->peer_login,"PASSTHRU") != 0)) {
1234#if USE_ADAPTATION
1235 // but allow adaptation services to authenticate clients
1236 // via request satisfaction
1238#endif
1240 }
1241
1243 // paranoid: ContentLengthInterpreter has cleaned non-generated replies
1245
1246 // if (request->range)
1247 // clientBuildRangeHeader(http, reply);
1248
1249 /*
1250 * Add a estimated Age header on cache hits.
1251 */
1252 if (is_hit) {
1253 /*
1254 * Remove any existing Age header sent by upstream caches
1255 * (note that the existing header is passed along unmodified
1256 * on cache misses)
1257 */
1259 /*
1260 * This adds the calculated object age. Note that the details of the
1261 * age calculation is performed by adjusting the timestamp in
1262 * StoreEntry::timestampsSet(), not here.
1263 */
1267 } else if (http->getConn() && http->getConn()->port->actAsOrigin) {
1268 // Swap the Date: header to current time if we are simulating an origin
1270 if (h)
1271 hdr->putExt("X-Origin-Date", h->value.termedBuf());
1275 if (h && http->storeEntry()->expires >= 0) {
1276 hdr->putExt("X-Origin-Expires", h->value.termedBuf());
1279 }
1281 // put X-Cache-Age: instead of Age:
1282 char age[64];
1283 snprintf(age, sizeof(age), "%" PRId64, static_cast<int64_t>(squid_curtime - http->storeEntry()->timestamp));
1284 hdr->putExt("X-Cache-Age", age);
1285 }
1286 } else if (http->storeEntry()->timestamp <= squid_curtime) {
1289 }
1290 }
1291
1292 /* RFC 2616: Section 14.18
1293 *
1294 * Add a Date: header if missing.
1295 * We have access to a clock therefore are required to amend any shortcoming in servers.
1296 *
1297 * NP: done after Age: to prevent ENTRY_SPECIAL double-handling this header.
1298 */
1299 if ( !hdr->has(Http::HdrType::DATE) ) {
1300 if (!http->storeEntry())
1302 else if (http->storeEntry()->timestamp > 0)
1304 else {
1305 debugs(88, DBG_IMPORTANT, "ERROR: Squid BUG #3279: HTTP reply without Date:");
1306 /* dump something useful about the problem */
1308 }
1309 }
1310
1311 /* Filter unproxyable authentication types */
1315 HttpHeaderEntry *e;
1316
1317 int connection_auth_blocked = 0;
1318 while ((e = hdr->getEntry(&pos))) {
1320 const char *value = e->value.rawBuf();
1321
1322 if ((strncasecmp(value, "NTLM", 4) == 0 &&
1323 (value[4] == '\0' || value[4] == ' '))
1324 ||
1325 (strncasecmp(value, "Negotiate", 9) == 0 &&
1326 (value[9] == '\0' || value[9] == ' '))
1327 ||
1328 (strncasecmp(value, "Kerberos", 8) == 0 &&
1329 (value[8] == '\0' || value[8] == ' '))) {
1330 if (request->flags.connectionAuthDisabled) {
1331 hdr->delAt(pos, connection_auth_blocked);
1332 continue;
1333 }
1334 request->flags.mustKeepalive = true;
1335 if (!request->flags.accelerated && !request->flags.intercepted) {
1336 httpHeaderPutStrf(hdr, Http::HdrType::PROXY_SUPPORT, "Session-Based-Authentication");
1337 /*
1338 We send "Connection: Proxy-Support" header to mark
1339 Proxy-Support as a hop-by-hop header for intermediaries that do not
1340 understand the semantics of this header. The RFC should have included
1341 this recommendation.
1342 */
1343 httpHeaderPutStrf(hdr, Http::HdrType::CONNECTION, "Proxy-support");
1344 }
1345 break;
1346 }
1347 }
1348 }
1349
1350 if (connection_auth_blocked)
1351 hdr->refreshMask();
1352 }
1353
1354#if USE_AUTH
1355 /* Handle authentication headers */
1359 ) {
1360 /* Add authentication header */
1361 /* TODO: alter errorstate to be accel on|off aware. The 0 on the next line
1362 * depends on authenticate behaviour: all schemes to date send no extra
1363 * data on 407/401 responses, and do not check the accel state on 401/407
1364 * responses
1365 */
1367 } else if (request->auth_user_request != nullptr)
1369#endif
1370
1371 SBuf cacheStatus(uniqueHostname());
1372 if (const auto hitOrFwd = http->loggingTags().cacheStatusSource())
1373 cacheStatus.append(hitOrFwd);
1374 if (firstStoreLookup_) {
1375 cacheStatus.append(";detail=");
1376 cacheStatus.append(firstStoreLookup_);
1377 }
1378 // TODO: Remove c_str() after converting HttpHeaderEntry::value to SBuf
1379 hdr->putStr(Http::HdrType::CACHE_STATUS, cacheStatus.c_str());
1380
1381 const bool maySendChunkedReply = !request->multipartRangeRequest() &&
1382 reply->sline.version.protocol == AnyP::PROTO_HTTP && // response is HTTP
1383 (request->http_ver >= Http::ProtocolVersion(1,1));
1384
1385 /* Check whether we should send keep-alive */
1386 if (!Config.onoff.error_pconns && reply->sline.status() >= 400 && !request->flags.mustKeepalive) {
1387 debugs(33, 3, "clientBuildReplyHeader: Error, don't keep-alive");
1388 request->flags.proxyKeepalive = false;
1389 } else if (!Config.onoff.client_pconns && !request->flags.mustKeepalive) {
1390 debugs(33, 2, "clientBuildReplyHeader: Connection Keep-Alive not requested by admin or client");
1391 request->flags.proxyKeepalive = false;
1392 } else if (request->flags.proxyKeepalive && shutting_down) {
1393 debugs(88, 3, "clientBuildReplyHeader: Shutting down, don't keep-alive.");
1394 request->flags.proxyKeepalive = false;
1395 } else if (request->flags.connectionAuth && !reply->keep_alive) {
1396 debugs(33, 2, "clientBuildReplyHeader: Connection oriented auth but server side non-persistent");
1397 request->flags.proxyKeepalive = false;
1398 } else if (reply->bodySize(request->method) < 0 && !maySendChunkedReply) {
1399 debugs(88, 3, "clientBuildReplyHeader: can't keep-alive, unknown body size" );
1400 request->flags.proxyKeepalive = false;
1401 } else if (fdUsageHigh()&& !request->flags.mustKeepalive) {
1402 debugs(88, 3, "clientBuildReplyHeader: Not many unused FDs, can't keep-alive");
1403 request->flags.proxyKeepalive = false;
1404 } else if (request->flags.sslBumped && !reply->persistent()) {
1405 // We do not really have to close, but we pretend we are a tunnel.
1406 debugs(88, 3, "clientBuildReplyHeader: bumped reply forces close");
1407 request->flags.proxyKeepalive = false;
1408 } else if (request->pinnedConnection() && !reply->persistent()) {
1409 // The peer wants to close the pinned connection
1410 debugs(88, 3, "pinned reply forces close");
1411 request->flags.proxyKeepalive = false;
1412 } else if (http->getConn()) {
1413 ConnStateData * conn = http->getConn();
1414 if (!Comm::IsConnOpen(conn->port->listenConn)) {
1415 // The listening port closed because of a reconfigure
1416 debugs(88, 3, "listening port closed");
1417 request->flags.proxyKeepalive = false;
1418 }
1419 }
1420
1421 // Decide if we send chunked reply
1422 if (maySendChunkedReply && reply->bodySize(request->method) < 0) {
1423 debugs(88, 3, "clientBuildReplyHeader: chunked reply");
1424 request->flags.chunkedReply = true;
1426 }
1427
1428 hdr->addVia(reply->sline.version);
1429
1430 /* Signal keep-alive or close explicitly */
1431 hdr->putStr(Http::HdrType::CONNECTION, request->flags.proxyKeepalive ? "keep-alive" : "close");
1432
1433 /* Surrogate-Control requires Surrogate-Capability from upstream to pass on */
1437 }
1438 /* TODO: else case: drop any controls intended specifically for our surrogate ID */
1439 }
1440
1441 httpHdrMangleList(hdr, request, http->al, ROR_REPLY);
1442}
1443
1444void
1446{
1447 assert(reply == nullptr);
1448
1451
1452 http->al->reply = reply;
1453
1455 /* RFC 2616 requires us to advertise our version (but only on real HTTP traffic) */
1457 }
1458
1459 /* do header conversions */
1461}
1462
1466void
1468{
1469 StoreEntry *e = http->storeEntry();
1470 assert(e); // or we are not dealing with a hit
1471 // We probably have not locked the entry earlier, unfortunately. We lock it
1472 // now so that we can unlock two lines later (and trigger cleanup).
1473 // Ideally, ClientHttpRequest::storeEntry() should lock/unlock, but it is
1474 // used so inconsistently that simply adding locking there leads to bugs.
1475 e->lock("clientReplyContext::forgetHit");
1476 http->storeEntry(nullptr);
1477 e->unlock("clientReplyContext::forgetHit"); // may delete e
1478}
1479
1480void
1482{
1483 HttpRequest *r = http->request;
1484
1485 // client sent CC:no-cache or some other condition has been
1486 // encountered which prevents delivering a public/cached object.
1487 // XXX: The above text does not match the condition below. It might describe
1488 // the opposite condition, but the condition itself should be adjusted
1489 // (e.g., to honor flags.noCache in cache manager requests).
1490 if (!r->flags.noCache || r->flags.internal) {
1491 const auto e = storeGetPublicByRequest(r);
1493 } else {
1494 // "external" no-cache requests skip Store lookups
1495 identifyFoundObject(nullptr, "no-cache");
1496 }
1497}
1498
1503void
1505{
1506 detailStoreLookup(detail);
1507
1508 HttpRequest *r = http->request;
1509 http->storeEntry(newEntry);
1510 const auto e = http->storeEntry();
1511
1512 /* Release IP-cache entries on reload */
1516 if (r->flags.noCache || r->flags.noCacheHack())
1518
1519 if (!e) {
1521 debugs(85, 3, "StoreEntry is NULL - MISS");
1523 doGetMoreData();
1524 return;
1525 }
1526
1527 if (Config.onoff.offline) {
1529 debugs(85, 3, "offline HIT " << *e);
1531 doGetMoreData();
1532 return;
1533 }
1534
1535 if (http->redirect.status) {
1537 debugs(85, 3, "REDIRECT status forced StoreEntry to NULL (no body on 3XX responses) " << *e);
1538 forgetHit();
1540 doGetMoreData();
1541 return;
1542 }
1543
1544 if (!e->validToSend()) {
1545 debugs(85, 3, "!storeEntryValidToSend MISS " << *e);
1546 forgetHit();
1548 doGetMoreData();
1549 return;
1550 }
1551
1552 if (EBIT_TEST(e->flags, ENTRY_SPECIAL)) {
1553 /* \li Special entries are always hits, no matter what the client says */
1554 debugs(85, 3, "ENTRY_SPECIAL HIT " << *e);
1556 doGetMoreData();
1557 return;
1558 }
1559
1560 if (r->flags.noCache) {
1561 debugs(85, 3, "no-cache REFRESH MISS " << *e);
1562 forgetHit();
1564 doGetMoreData();
1565 return;
1566 }
1567
1568 if (e->hittingRequiresCollapsing() && !startCollapsingOn(*e, false)) {
1569 debugs(85, 3, "prohibited CF MISS " << *e);
1570 forgetHit();
1572 doGetMoreData();
1573 return;
1574 }
1575
1576 debugs(85, 3, "default HIT " << *e);
1578 doGetMoreData();
1579}
1580
1582void
1584{
1585 if (!firstStoreLookup_) {
1586 debugs(85, 7, detail);
1587 firstStoreLookup_ = detail;
1588 } else {
1589 debugs(85, 7, "ignores " << detail << " after " << firstStoreLookup_);
1590 }
1591}
1592
1602void
1604{
1605 /* Test preconditions */
1606 assert(aNode != nullptr);
1608 assert(aNode->node.prev == nullptr);
1609 assert(aNode->node.next != nullptr);
1610 clientReplyContext *context = dynamic_cast<clientReplyContext *>(aNode->data.getRaw());
1611 assert (context);
1612 assert(context->http == http);
1613
1614 if (!context->ourNode)
1615 context->ourNode = aNode;
1616
1617 /* no cbdatareference, this is only used once, and safely */
1618 if (context->flags.storelogiccomplete) {
1619 context->requestMoreBodyFromStore();
1620 return;
1621 }
1622
1623 if (context->http->request->method == Http::METHOD_PURGE) {
1624 context->purgeRequest();
1625 return;
1626 }
1627
1628 // OPTIONS with Max-Forwards:0 handled in clientProcessRequest()
1629
1630 if (context->http->request->method == Http::METHOD_TRACE) {
1632 context->traceReply();
1633 return;
1634 }
1635
1636 /* continue forwarding, not finished yet. */
1638
1639 context->doGetMoreData();
1640 } else
1641 context->identifyStoreObject();
1642}
1643
1644void
1646{
1647 /* We still have to do store logic processing - vary, cache hit etc */
1648 if (http->storeEntry() != nullptr) {
1649 /* someone found the object in the cache for us */
1650 StoreIOBuffer localTempBuffer;
1651
1652 http->storeEntry()->lock("clientReplyContext::doGetMoreData");
1653
1655
1657#if USE_DELAY_POOLS
1659#endif
1660
1662 /* guarantee nothing has been sent yet! */
1663 assert(http->out.size == 0);
1664 assert(http->out.offset == 0);
1665
1666 if (ConnStateData *conn = http->getConn()) {
1667 if (Ip::Qos::TheConfig.isHitTosActive()) {
1668 Ip::Qos::doTosLocalHit(conn->clientConnection);
1669 }
1670
1671 if (Ip::Qos::TheConfig.isHitNfmarkActive()) {
1672 Ip::Qos::doNfmarkLocalHit(conn->clientConnection);
1673 }
1674 }
1675
1677 } else {
1678 /* MISS CASE, http->loggingTags() are already set! */
1679 processMiss();
1680 }
1681}
1682
1684void
1690
1695void
1697{
1698 clientReplyContext *context = static_cast<clientReplyContext *>(data);
1699 context->sendMoreData (result);
1700}
1701
1702void
1704{
1705 /* At least, I think that's what this does */
1708}
1709
1710bool
1712{
1713 return /* aborted request */
1715 /* Upstream read error */ (result.flags.error);
1716}
1717
1718void
1720{
1726 debugs(88, 5, "A stream error has occurred, marking as complete and sending no data.");
1727 StoreIOBuffer localTempBuffer;
1728 flags.complete = 1;
1729 http->request->flags.streamError = true;
1730 localTempBuffer.flags.error = result.flags.error;
1732 localTempBuffer);
1733}
1734
1735void
1737{
1738 if (result.length == 0) {
1739 debugs(88, 5, "clientReplyContext::pushStreamData: marking request as complete due to 0 length store result");
1740 flags.complete = 1;
1741 }
1742
1743 assert(!result.length || result.offset == next()->readBuffer.offset);
1745 result);
1746}
1747
1754
1755void
1766
1768void
1779
1781void
1783{
1784 StoreEntry *e = http->storeEntry();
1785 const time_t timestamp = e->timestamp;
1786 const auto temprep = e->mem().freshestReply().make304();
1787 // log as TCP_INM_HIT if code 304 generated for
1788 // If-None-Match request
1789 if (!http->request->flags.ims)
1791 else
1795 e = http->storeEntry();
1796 // Copy timestamp from the original entry so the 304
1797 // reply has a meaningful Age: header.
1798 e->timestampsSet();
1799 e->timestamp = timestamp;
1800 e->replaceHttpReply(temprep);
1801 e->complete();
1802 /*
1803 * TODO: why put this in the store and then serialise it and
1804 * then parse it again. Simply mark the request complete in
1805 * our context and write the reply struct to the client side.
1806 */
1808}
1809
1812void
1821
1822void
1824{
1825 /* NP: this should probably soft-fail to a zero-sized-reply error ?? */
1826 assert(reply);
1827
1833 return;
1834 }
1835
1839 return;
1840 }
1841
1843 if (!Config.accessList.reply) {
1845 return;
1846 }
1847
1849 auto replyChecklist =
1851 replyChecklist->updateReply(reply);
1852 ACLFilledChecklist::NonBlockingCheck(std::move(replyChecklist), ProcessReplyAccessResult, this);
1853}
1854
1855void
1857{
1858 clientReplyContext *me = static_cast<clientReplyContext *>(voidMe);
1860}
1861
1862void
1864{
1865 debugs(88, 2, "The reply for " << http->request->method
1866 << ' ' << http->uri << " is " << accessAllowed << ", because it matched "
1867 << accessAllowed.lastCheckDescription());
1868
1869 if (!accessAllowed.allowed()) {
1870 ErrorState *err;
1871 auto page_id = FindDenyInfoPage(accessAllowed, true);
1872
1874
1875 if (page_id == ERR_NONE)
1876 page_id = ERR_ACCESS_DENIED;
1877
1878 err = clientBuildError(page_id, Http::scForbidden, nullptr,
1879 http->getConn(), http->request, http->al);
1880
1882
1884
1885 startError(err);
1886
1887 return;
1888 }
1889
1890 /* Ok, the reply is allowed, */
1892
1895 auto body_size = lastStreamBufferedBytes.length; // may be zero
1896
1897 debugs(88, 3, "clientReplyContext::sendMoreData: Appending " <<
1898 (int) body_size << " bytes after " << reply->hdr_sz <<
1899 " bytes of headers");
1900
1902 /* do not forward body for HEAD replies */
1903 body_size = 0;
1904 http->flags.done_copying = true;
1905 flags.complete = 1;
1906 }
1907
1909 flags.headersSent = true;
1910
1911 // next()->readBuffer.offset may be positive for Range requests, but our
1912 // localTempBuffer initialization code assumes that next()->readBuffer.data
1913 // points to the response body at offset 0 because the first
1914 // storeClientCopy() request always has offset 0 (i.e. our first Store
1915 // request ignores next()->readBuffer.offset).
1916 //
1917 // XXX: We cannot fully check that assumption: readBuffer.offset field is
1918 // often out of sync with the buffer content, and if some buggy code updates
1919 // the buffer while we were waiting for the processReplyAccessResult()
1920 // callback, we may not notice.
1921
1922 StoreIOBuffer localTempBuffer;
1923 const auto body_buf = next()->readBuffer.data;
1924
1925 //Server side may disable ranges under some circumstances.
1926
1927 if ((!http->request->range))
1928 next()->readBuffer.offset = 0;
1929
1930 if (next()->readBuffer.offset > 0) {
1931 if (Less(body_size, next()->readBuffer.offset)) {
1932 /* Can't use any of the body we received. send nothing */
1933 localTempBuffer.length = 0;
1934 localTempBuffer.data = nullptr;
1935 } else {
1936 localTempBuffer.length = body_size - next()->readBuffer.offset;
1937 localTempBuffer.data = body_buf + next()->readBuffer.offset;
1938 }
1939 } else {
1940 localTempBuffer.length = body_size;
1941 localTempBuffer.data = body_buf;
1942 }
1943
1945 http, reply, localTempBuffer);
1946
1947 return;
1948}
1949
1950void
1952{
1953 if (deleting)
1954 return;
1955
1956 debugs(88, 5, http->uri << " got " << result);
1957
1958 StoreEntry *entry = http->storeEntry();
1959
1960 if (ConnStateData * conn = http->getConn()) {
1961 if (!conn->isOpen()) {
1962 debugs(33,3, "not sending more data to closing connection " << conn->clientConnection);
1963 return;
1964 }
1965 if (conn->pinning.zeroReply) {
1966 debugs(33,3, "not sending more data after a pinned zero reply " << conn->clientConnection);
1967 return;
1968 }
1969
1970 if (!flags.headersSent && !http->loggingTags().isTcpHit()) {
1971 // We get here twice if processReplyAccessResult() calls startError().
1972 // TODO: Revise when we check/change QoS markings to reduce syscalls.
1973 if (Ip::Qos::TheConfig.isHitTosActive()) {
1974 Ip::Qos::doTosLocalMiss(conn->clientConnection, http->request->hier.code);
1975 }
1976 if (Ip::Qos::TheConfig.isHitNfmarkActive()) {
1977 Ip::Qos::doNfmarkLocalMiss(conn->clientConnection, http->request->hier.code);
1978 }
1979 }
1980
1981 debugs(88, 5, conn->clientConnection <<
1982 " '" << entry->url() << "'" <<
1983 " out.offset=" << http->out.offset);
1984 }
1985
1986 /* We've got the final data to start pushing... */
1988
1989 assert(http->request != nullptr);
1990
1991 /* ESI TODO: remove this assert once everything is stable */
1994
1995 makeThisHead();
1996
1997 if (errorInStream(result)) {
1998 sendStreamError(result);
1999 return;
2000 }
2001
2002 if (!matchesStreamBodyBuffer(result)) {
2003 // Subsequent processing expects response body bytes to be at the start
2004 // of our Client Stream buffer. When given something else (e.g., bytes
2005 // in our tempbuf), we copy and adjust to meet those expectations.
2006 const auto &ourClientStreamsBuffer = next()->readBuffer;
2007 assert(result.length <= ourClientStreamsBuffer.length);
2008 memcpy(ourClientStreamsBuffer.data, result.data, result.length);
2009 result.data = ourClientStreamsBuffer.data;
2010 }
2011
2013
2014 if (flags.headersSent) {
2015 pushStreamData(result);
2016 return;
2017 }
2018
2019 cloneReply();
2020
2021#if USE_DELAY_POOLS
2022 if (sc)
2024#endif
2025
2027 return;
2028}
2029
2032bool
2034{
2035 // the answer is undefined for errors; they are not really "body buffers"
2036 Assure(!their.flags.error);
2037
2038 if (!their.length)
2039 return true; // an empty body area always matches our body area
2040
2041 if (their.data != next()->readBuffer.data) {
2042 debugs(88, 7, "no: " << their << " vs. " << next()->readBuffer);
2043 return false;
2044 }
2045
2046 return true;
2047}
2048
2049void
2051{
2053 lastStreamBufferedBytes = result; // may be unchanged and/or zero-length
2054}
2055
2056void
2061
2062/* Using this breaks the client layering just a little!
2063 */
2064void
2066{
2067 assert(http != nullptr);
2068 /*
2069 * For erroneous requests, we might not have a h->request,
2070 * so make a fake one.
2071 */
2072
2073 if (http->request == nullptr) {
2074 const auto connManager = http->getConn();
2075 const auto mx = MasterXaction::MakePortful(connManager ? connManager->port : nullptr);
2076 // XXX: These fake URI parameters shadow the real (or error:...) URI.
2077 // TODO: Either always set the request earlier and assert here OR use
2078 // http->uri (converted to Anyp::Uri) to create this catch-all request.
2079 const_cast<HttpRequest *&>(http->request) = new HttpRequest(m, AnyP::PROTO_NONE, "http", null_string, mx);
2081 }
2082
2083 StoreEntry *e = storeCreateEntry(storeId(), http->log_uri, reqFlags, m);
2084
2085 // Make entry collapsible ASAP, to increase collapsing chances for others,
2086 // TODO: every must-revalidate and similar request MUST reach the origin,
2087 // but do we have to prohibit others from collapsing on that request?
2088 if (reqFlags.cachable &&
2089 !reqFlags.needValidation &&
2090 (m == Http::METHOD_GET || m == Http::METHOD_HEAD) &&
2092 // make the entry available for future requests now
2093 (void)Store::Root().allowCollapsing(e, reqFlags, m);
2094 }
2095
2096 sc = storeClientListAdd(e, this);
2097
2098#if USE_DELAY_POOLS
2100#endif
2101
2102 /* The next line is illegal because we don't know if the client stream
2103 * buffers have been set up
2104 */
2105 // storeClientCopy(http->sc, e, 0, HTTP_REQBUF_SZ, http->reqbuf,
2106 // SendMoreData, this);
2107 /* So, we mark the store logic as complete */
2109
2110 /* and get the caller to request a read, from wherever they are */
2111 /* NOTE: after ANY data flows down the pipe, even one step,
2112 * this function CAN NOT be used to manage errors
2113 */
2114 http->storeEntry(e);
2115}
2116
2117ErrorState *
2118clientBuildError(err_type page_id, Http::StatusCode status, char const *url,
2119 const ConnStateData *conn, HttpRequest *request, const AccessLogEntry::Pointer &al)
2120{
2121 const auto err = new ErrorState(page_id, status, request, al);
2122 err->src_addr = conn && conn->clientConnection ? conn->clientConnection->remote : Ip::Address::NoAddr();
2123
2124 if (url)
2125 err->url = xstrdup(url);
2126
2127 return err;
2128}
2129
#define Assure(condition)
Definition Assure.h:35
void httpHdrMangleList(HttpHeader *l, HttpRequest *request, const AccessLogEntryPointer &al, req_or_rep_t req_or_rep)
@ ROR_REPLY
void httpHeaderPutStrf(HttpHeader *hdr, Http::HdrType id, const char *fmt,...)
ssize_t HttpHeaderPos
Definition HttpHeader.h:45
#define HttpHeaderInitPos
Definition HttpHeader.h:48
@ LOG_TCP_REFRESH_FAIL_ERR
Definition LogTags.h:46
@ LOG_TCP_DENIED
Definition LogTags.h:55
@ LOG_TCP_REFRESH
Definition LogTags.h:48
@ LOG_TCP_NEGATIVE_HIT
Definition LogTags.h:53
@ LOG_TCP_REFRESH_MODIFIED
Definition LogTags.h:47
@ LOG_TCP_REDIRECT
Definition LogTags.h:58
@ LOG_TCP_OFFLINE_HIT
Definition LogTags.h:57
@ LOG_TCP_HIT
Definition LogTags.h:42
@ LOG_TCP_REFRESH_FAIL_OLD
Definition LogTags.h:45
@ LOG_TCP_MISS
Definition LogTags.h:43
@ LOG_TCP_MEM_HIT
Definition LogTags.h:54
@ LOG_TCP_IMS_HIT
Definition LogTags.h:50
@ LOG_TCP_REFRESH_UNMODIFIED
Definition LogTags.h:44
@ LOG_TCP_DENIED_REPLY
Definition LogTags.h:56
@ LOG_TCP_SWAPFAIL_MISS
Definition LogTags.h:52
@ LOG_TCP_CLIENT_REFRESH_MISS
Definition LogTags.h:49
@ LOG_TCP_INM_HIT
Definition LogTags.h:51
time_t squid_curtime
class SquidConfig Config
class SquidConfig2 Config2
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)
err_type FindDenyInfoPage(const Acl::Answer &answer, const bool redirect_allowed)
Definition Gadgets.cc:34
#define assert(EX)
Definition assert.h:17
#define USE_AUTH
Definition autoconf.h:1502
int cbdataReferenceValid(const void *p)
Definition cbdata.cc:270
#define cbdataReferenceDone(var)
Definition cbdata.h:357
#define cbdataReference(var)
Definition cbdata.h:348
#define CBDATA_CLASS_INIT(type)
Definition cbdata.h:325
Acl::Answer const & fastCheck()
Definition Checklist.cc:298
static void NonBlockingCheck(MakingPointer &&p, ACLCB *cb, void *data)
void updateReply(const HttpReply::Pointer &)
HttpReplyPointer reply
class AccessLogEntry::CacheDetails cache
class AccessLogEntry::HttpDetails http
const SBuf & lastCheckDescription() const
describes the ACL that was evaluated last while obtaining this answer (for debugging)
Definition Acl.cc:123
bool allowed() const
Definition Acl.h:82
ProtocolType protocol
which protocol this version is for
AnyP::UriScheme const & getScheme() const
Definition Uri.h:58
void host(const char *src)
Definition Uri.cc:154
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.
struct ClientHttpRequest::Out out
HttpRequest *const request
ConnStateData * getConn() const
void updateLoggingTags(const LogTags_ot code)
update the code in the transaction processing tags
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
Ip::Address remote
Definition Connection.h:152
AnyP::Port port
destination port of the request that caused serverConnection
static DelayId DelayClient(ClientHttpRequest *, HttpReply *reply=nullptr)
Definition DelayId.cc:64
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:338
void set(const SBuf &newContent)
Definition HttpBody.h:26
Http::HdrType id
Definition HttpHeader.h:66
void removeHopByHopEntries()
void putStr(Http::HdrType id, const char *str)
void delAt(HttpHeaderPos pos, int &headers_deleted)
void putInt(Http::HdrType id, int number)
int delById(Http::HdrType id)
void refreshMask()
HttpHeaderEntry * getEntry(HttpHeaderPos *pos) const
void addVia(const AnyP::ProtocolVersion &ver, const HttpHeader *from=nullptr)
int has(Http::HdrType id) const
int64_t getInt64(Http::HdrType id) const
HttpHeaderEntry * findEntry(Http::HdrType id) const
void putExt(const char *name, const char *value)
void putTime(Http::HdrType id, time_t htime)
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
HttpBody body
Definition HttpReply.h:58
void removeIrrelevantContentLength()
Some response status codes prohibit sending Content-Length (RFC 7230 section 3.3.2).
Definition HttpReply.cc:646
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:611
short int keep_alive
Definition HttpReply.h:53
bool conditional() const
has at least one recognized If-* header
HttpHdrRange * range
CbcPointer< ConnStateData > clientConnectionManager
HttpRequestMethod method
bool multipartRangeRequest() const
void pack(Packable *p, bool maskSensitiveInfo=false) const
HierarchyLogEntry hier
time_t lastmod
RequestFlags flags
SBuf vary_headers
The variant second-stage cache key. Generated from Vary header pattern for this request.
String etag
A strong etag of the cached entry. Used for refreshing that entry.
ConnStateData * pinnedConnection()
void ignoreRange(const char *reason)
forgets about the cached Range header (for a reason)
char * peer_login
const SBuf storeId()
Auth::UserRequest::Pointer auth_user_request
AnyP::Uri url
the request URI
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
bool persistent() const
Definition Message.cc:236
HttpHeader header
Definition Message.h:74
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:321
bool ignored
_IGNORED: the response was not used for anything
Definition LogTags.h:27
const char * c_str() const
compute the status access.log field
Definition LogTags.cc:75
const char * cacheStatusSource() const
Definition LogTags.cc:124
LogTagsErrors err
various problems augmenting the primary log tag
Definition LogTags.h:87
LogTags_ot oldType
a set of client protocol, cache use, and other transaction outcome tags
Definition LogTags.h:96
bool isTcpHit() const
determine if the log tag code indicates a cache HIT
Definition LogTags.cc:110
static Pointer MakePortful(const AnyP::PortCfgPointer &aPort)
void init(mb_size_t szInit, mb_size_t szMax)
Definition MemBuf.cc:93
mb_size_t size
Definition MemBuf.h:135
char * buf
Definition MemBuf.h:134
mb_size_t contentSize() const
available data size
Definition MemBuf.h:47
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
bool connectionAuth
bool noCacheHack() const
bool proxyKeepalive
bool failOnValidationError
bool connectionAuthDisabled
SupportOrVeto cachable
whether the response may be stored in the cache
Definition SBuf.h:94
static const size_type npos
Definition SBuf.h:100
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:279
size_type find(char c, size_type startPos=0) const
Definition SBuf.cc:584
bool isEmpty() const
Definition SBuf.h:435
SBuf & append(const SBuf &S)
Definition SBuf.cc:185
Comm::ConnectionPointer clientConnection
Definition Server.h:100
struct SquidConfig2::@102 onoff
acl_access * reply
struct SquidConfig::@90 onoff
int collapsed_forwarding
acl_access * sendHit
struct SquidConfig::@91 accessList
bool didCollapse
whether startCollapsingOn() was called and returned true
Definition StoreClient.h:64
bool mayInitiateCollapsing() const
whether Squid configuration allows us to become a CF initiator
Definition StoreClient.h:59
bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const
void completeSuccessfully(const char *whyWeAreSureWeStoredTheWholeReply)
Definition store.cc:1017
mem_status_t mem_status
Definition Store.h:239
uint16_t flags
Definition Store.h:231
MemObject & mem()
Definition Store.h:47
bool hasIfMatchEtag(const HttpRequest &request) const
has ETag matching at least one of the If-Match etags
Definition store.cc:1873
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:1589
bool hasIfNoneMatchEtag(const HttpRequest &request) const
has ETag matching at least one of the If-None-Match etags
Definition store.cc:1880
void dump(int debug_lvl) const
Definition store.cc:1499
int unlock(const char *context)
Definition store.cc:469
const char * url() const
Definition store.cc:1566
void complete()
Definition store.cc:1031
time_t expires
Definition Store.h:225
bool hasEtag(ETag &etag) const
whether this entry has an ETag; if yes, puts ETag value into parameter
Definition store.cc:1862
void lastModified(const time_t when)
Definition Store.h:175
void release(const bool shareable=false)
Definition store.cc:1146
bool hasParsedReplyHeader() const
whether this entry has access to [deserialized] [HTTP] response headers
Definition store.cc:231
void lock(const char *context)
Definition store.cc:445
time_t timestamp
Definition Store.h:223
bool timestampsSet()
Definition store.cc:1387
void clearPublicKeyScope()
Definition store.cc:609
void storeErrorResponse(HttpReply *reply)
Store a prepared error response. MemObject locks the reply object.
Definition store.cc:1688
bool mayStartHitting() const
Definition Store.h:284
int checkNegativeHit() const
Definition store.cc:1300
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
Definition store.cc:1705
MemObject * mem_obj
Definition Store.h:220
bool modifiedSince(const time_t ims, const int imslen=-1) const
Definition store.cc:1836
int64_t objectLen() const
Definition Store.h:253
store_status_t store_status
Definition Store.h:243
void buffer() override
Definition store.cc:1601
void releaseRequest(const bool shareable=false)
Definition store.cc:458
struct StoreIOBuffer::@123 flags
bool allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &)
tries to make the entry available for collapsing future requests
static bool SmpAware()
whether there are any SMP-aware storages
void evictIfFound(const cache_key *) override
void clean()
Definition String.cc:104
char const * rawBuf() const
Definition SquidString.h:87
char const * termedBuf() const
Definition SquidString.h:93
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
void sendPreconditionFailedError()
send 412 (Precondition Failed) to client
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)
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
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
clientReplyContext(ClientHttpRequest *)
void detailStoreLookup(const char *detail)
remembers the very first Store lookup classification, ignoring the rest
StoreIOBuffer readBuffer
ClientStreamData data
dlink_node node
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 *)
ACLFilledChecklist::MakingPointer clientAclChecklistCreate(const acl_access *acl, ClientHttpRequest *http)
int varyEvaluateMatch(StoreEntry *entry, HttpRequest *request)
void clientAclChecklistFill(ACLFilledChecklist &checklist, ClientHttpRequest *http)
CSS clientReplyStatus
ErrorState * clientBuildError(err_type, Http::StatusCode, char const *, const ConnStateData *, HttpRequest *, const AccessLogEntry::Pointer &)
CSD clientReplyDetach
void purgeEntriesByUrl(HttpRequest *req, const char *url)
CSR clientGetMoreData
void purgeEntriesByUrl(HttpRequest *, const char *)
#define DBG_IMPORTANT
Definition Stream.h:38
#define debugs(SECTION, LEVEL, CONTENT)
Definition Stream.h:192
#define DBG_CRITICAL
Definition Stream.h:37
#define EBIT_TEST(flag, bit)
Definition defines.h:67
@ ENTRY_BAD_LENGTH
Definition enums.h:109
@ ENTRY_SPECIAL
Definition enums.h:79
@ ENTRY_ABORTED
Definition enums.h:110
@ VARY_OTHER
Definition enums.h:190
@ VARY_NONE
Definition enums.h:188
@ VARY_CANCEL
Definition enums.h:191
@ VARY_MATCH
Definition enums.h:189
@ IN_MEMORY
Definition enums.h:31
@ HTCP_CLR_INVALIDATION
Definition enums.h:236
@ HTCP_CLR_PURGE
Definition enums.h:235
clientStream_status_t
Definition enums.h:120
@ STREAM_COMPLETE
Definition enums.h:122
@ STREAM_UNPLANNED_COMPLETE
Definition enums.h:127
@ STREAM_NONE
Definition enums.h:121
@ STREAM_FAILED
Definition enums.h:132
@ STORE_OK
Definition enums.h:45
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:268
int shutting_down
const char * null_string
@ ACCESS_ALLOWED
Definition Acl.h:42
void clientStreamCallback(clientStreamNode *thisObject, ClientHttpRequest *http, HttpReply *rep, StoreIOBuffer replyBuffer)
void clientStreamDetach(clientStreamNode *thisObject, ClientHttpRequest *http)
void errorAppendEntry(StoreEntry *entry, ErrorState *err)
Definition errorpage.cc:738
void ipcacheInvalidateNegative(const char *name)
Definition ipcache.cc:882
void ipcacheInvalidate(const char *name)
Definition ipcache.cc:865
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
@ PROTO_HTTPS
@ PROTO_HTTP
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:77
@ scForbidden
Definition StatusCode.h:48
@ scUnauthorized
Definition StatusCode.h:46
@ scNotImplemented
Definition StatusCode.h:74
@ scInternalServerError
Definition StatusCode.h:73
@ scNotFound
Definition StatusCode.h:49
@ scProxyAuthenticationRequired
Definition StatusCode.h:52
@ scNone
Definition StatusCode.h:21
@ scNotModified
Definition StatusCode.h:41
@ scOkay
Definition StatusCode.h:27
@ scContinue
Definition StatusCode.h:22
@ scNoContent
Definition StatusCode.h:31
@ scSwitchingProtocols
Definition StatusCode.h:23
@ scPreconditionFailed
Definition StatusCode.h:57
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
AnyP::ProtocolVersion ProtocolVersion()
@ IF_MODIFIED_SINCE
@ TRANSFER_ENCODING
@ SURROGATE_CAPABILITY
@ PROXY_AUTHENTICATE
int doNfmarkLocalHit(const Comm::ConnectionPointer &conn)
Definition QosConfig.cc:280
Config TheConfig
Globally available instance of Qos::Config.
Definition QosConfig.cc:288
int doTosLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode)
Definition QosConfig.cc:231
int doNfmarkLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode)
Definition QosConfig.cc:252
int doTosLocalHit(const Comm::ConnectionPointer &conn)
Definition QosConfig.cc:273
Controller & Root()
safely access controller singleton
#define xstrdup
void neighborsHtcpClear(StoreEntry *e, HttpRequest *req, const HttpRequestMethod &method, htcp_clr_reason reason)
int refreshCheckHTTP(const StoreEntry *entry, HttpRequest *request)
Definition refresh.cc:582
unsigned char cache_key
Store key.
Definition forward.h:29
StoreEntry * storeGetPublicByRequestMethod(HttpRequest *req, const HttpRequestMethod &method, const KeyScope keyScope)
Definition store.cc:510
StoreEntry * storeGetPublicByRequest(HttpRequest *req, const KeyScope keyScope)
Definition store.cc:516
StoreEntry * storeCreateEntry(const char *url, const char *logUrl, const RequestFlags &flags, const HttpRequestMethod &method)
Definition store.cc:759
StoreEntry * storeGetPublic(const char *uri, const HttpRequestMethod &method)
Definition store.cc:504
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
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:548
#define PRId64
Definition types.h:104