client_side_reply.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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 "Store.h"
37#include "StrList.h"
38#include "tools.h"
39#if USE_AUTH
40#include "auth/UserRequest.h"
41#endif
42#if USE_DELAY_POOLS
43#include "DelayPools.h"
44#endif
45#if USE_SQUID_ESI
46#include "esi/Esi.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() */
72}
73
75 purgeStatus(Http::scNone),
76 http(cbdataReference(clientContext)),
77 headers_sz(0),
78 sc(nullptr),
79 old_reqsize(0),
80 reqsize(0),
81 reqofs(0),
82 ourNode(nullptr),
83 reply(nullptr),
84 old_entry(nullptr),
85 old_sc(nullptr),
86 old_lastmod(-1),
87 deleting(false),
88 collapsedRevalidation(crNone)
89{
90 *tempbuf = 0;
91}
92
98void
100 err_type err, Http::StatusCode status, char const *uri,
101 const ConnStateData *conn, HttpRequest *failedrequest, const char *unparsedrequest,
102#if USE_AUTH
103 Auth::UserRequest::Pointer auth_user_request
104#else
105 void*
106#endif
107)
108{
109 auto errstate = clientBuildError(err, status, uri, conn, failedrequest, http->al);
110
111 if (unparsedrequest)
112 errstate->request_hdrs = xstrdup(unparsedrequest);
113
114#if USE_AUTH
115 errstate->auth_user_request = auth_user_request;
116#endif
117 setReplyToError(failedrequest ? failedrequest->method : HttpRequestMethod(Http::METHOD_NONE), errstate);
118}
119
121{
122 if (errstate->httpStatus == Http::scNotImplemented && http->request)
123 /* prevent confusion over whether we default to persistent or not */
125
126 http->al->http.code = errstate->httpStatus;
127
128 if (http->request)
129 http->request->ignoreRange("responding with a Squid-generated error");
130
132 assert(errstate->callback_data == nullptr);
133 errorAppendEntry(http->storeEntry(), errstate);
134 /* Now the caller reads to get this */
135}
136
137void
139{
140 Must(futureReply);
141 http->al->http.code = futureReply->sline.status();
142
143 HttpRequestMethod method;
144 if (http->request) { // nil on responses to unparsable requests
145 http->request->ignoreRange("responding with a Squid-generated reply");
146 method = http->request->method;
147 }
148
150
151 http->storeEntry()->storeErrorResponse(futureReply);
152 /* Now the caller reads to get futureReply */
153}
154
155// Assumes that the entry contains an error response without Content-Range.
156// To use with regular entries, make HTTP Range header removal conditional.
158{
159 entry->lock("clientReplyContext::setReplyToStoreEntry"); // removeClientStoreReference() unlocks
160 sc = storeClientListAdd(entry, this);
161#if USE_DELAY_POOLS
163#endif
164 reqofs = 0;
165 reqsize = 0;
166 if (http->request)
167 http->request->ignoreRange(reason);
169 http->storeEntry(entry);
170}
171
172void
174 StoreEntry ** ep)
175{
176 StoreEntry *e;
177 store_client *sc_tmp = *scp;
178
179 if ((e = *ep) != nullptr) {
180 *ep = nullptr;
181 storeUnregister(sc_tmp, e, this);
182 *scp = nullptr;
183 e->unlock("clientReplyContext::removeStoreReference");
184 }
185}
186
187void
189{
190 StoreEntry *reference = aHttpRequest->storeEntry();
191 removeStoreReference(scp, &reference);
192 aHttpRequest->storeEntry(reference);
193}
194
195void
197{
198 assert(old_sc == nullptr);
199 debugs(88, 3, "clientReplyContext::saveState: saving store context");
201 old_sc = sc;
206 /* Prevent accessing the now saved entries */
207 http->storeEntry(nullptr);
208 sc = nullptr;
209 reqsize = 0;
210 reqofs = 0;
211}
212
213void
215{
216 assert(old_sc != nullptr);
217 debugs(88, 3, "clientReplyContext::restoreState: Restoring store context");
220 sc = old_sc;
225 /* Prevent accessed the old saved entries */
226 old_entry = nullptr;
227 old_sc = nullptr;
228 old_lastmod = -1;
229 old_etag.clean();
230 old_reqsize = 0;
231 tempBuffer.offset = 0;
232}
233
234void
236{
240}
241
244{
246}
247
248/* This function is wrong - the client parameters don't include the
249 * header offset
250 */
251void
253{
254 /* when confident, 0 becomes reqofs, and then this factors into
255 * startSendProcess
256 */
257 assert(reqofs == 0);
258 StoreIOBuffer localTempBuffer (next()->readBuffer.length, 0, next()->readBuffer.data);
259 storeClientCopy(sc, http->storeEntry(), localTempBuffer, SendMoreData, this);
260}
261
262/* there is an expired entry in the store.
263 * setup a temporary buffer area and perform an IMS to the origin
264 */
265void
267{
268 const char *url = storeId();
269 debugs(88, 3, "clientReplyContext::processExpired: '" << http->uri << "'");
270 const time_t lastmod = http->storeEntry()->lastModified();
271 assert(lastmod >= 0);
272 /*
273 * check if we are allowed to contact other servers
274 * @?@: Instead of a 504 (Gateway Timeout) reply, we may want to return
275 * a stale entry *if* it matches client requirements
276 */
277
278 if (http->onlyIfCached()) {
280 return;
281 }
282
284 http->request->flags.refresh = true;
285#if STORE_CLIENT_LIST_DEBUG
286 /* Prevent a race with the store client memory free routines
287 */
289#endif
290 /* Prepare to make a new temporary request */
291 saveState();
292
293 // TODO: Consider also allowing regular (non-collapsed) revalidation hits.
294 // TODO: support collapsed revalidation for Vary-controlled entries
295 bool collapsingAllowed = Config.onoff.collapsed_forwarding &&
298
299 StoreEntry *entry = nullptr;
300 if (collapsingAllowed) {
301 if (const auto e = storeGetPublicByRequest(http->request, ksRevalidation)) {
302 if (e->hittingRequiresCollapsing() && startCollapsingOn(*e, true)) {
303 entry = e;
304 entry->lock("clientReplyContext::processExpired#alreadyRevalidating");
305 } else {
306 e->abandon(__FUNCTION__);
307 // assume mayInitiateCollapsing() would fail too
308 collapsingAllowed = false;
309 }
310 }
311 }
312
313 if (entry) {
315 debugs(88, 5, "collapsed on existing revalidation entry: " << *entry);
317 } else {
318 entry = storeCreateEntry(url,
320 /* NOTE, don't call StoreEntry->lock(), storeCreateEntry() does it */
321
322 if (collapsingAllowed && mayInitiateCollapsing() &&
323 Store::Root().allowCollapsing(entry, http->request->flags, http->request->method)) {
324 debugs(88, 5, "allow other revalidation requests to collapse on " << *entry);
326 } else {
328 }
329 }
330
331 sc = storeClientListAdd(entry, this);
332#if USE_DELAY_POOLS
333 /* delay_id is already set on original store client */
335#endif
336
337 http->request->lastmod = lastmod;
338
340 ETag etag = {nullptr, -1}; // TODO: make that a default ETag constructor
341 if (old_entry->hasEtag(etag) && !etag.weak)
342 http->request->etag = etag.str;
343 }
344
345 debugs(88, 5, "lastmod " << entry->lastModified());
346 http->storeEntry(entry);
347 assert(http->out.offset == 0);
349
351 /*
352 * A refcounted pointer so that FwdState stays around as long as
353 * this clientReplyContext does
354 */
355 Comm::ConnectionPointer conn = http->getConn() != nullptr ? http->getConn()->clientConnection : nullptr;
357 }
358 /* Register with storage manager to receive updates when data comes in. */
359
360 if (EBIT_TEST(entry->flags, ENTRY_ABORTED))
361 debugs(88, DBG_CRITICAL, "clientReplyContext::processExpired: Found ENTRY_ABORTED object");
362
363 {
364 /* start counting the length from 0 */
365 StoreIOBuffer localTempBuffer(HTTP_REQBUF_SZ, 0, tempbuf);
366 storeClientCopy(sc, entry, localTempBuffer, HandleIMSReply, this);
367 }
368}
369
370void
372{
373 StoreIOBuffer tempresult;
375
378
379 /* here the data to send is the data we just received */
380 tempBuffer.offset = 0;
381 old_reqsize = 0;
382 /* sendMoreData tracks the offset as well.
383 * Force it back to zero */
384 reqofs = 0;
386 /* TODO: provide sendMoreData with the ready parsed reply */
387 tempresult.length = reqsize;
388 tempresult.data = tempbuf;
389 sendMoreData(tempresult);
390}
391
392void
394{
395 clientReplyContext *context = (clientReplyContext *)data;
396 context->handleIMSReply(result);
397}
398
399void
401{
402 /* Get the old request back */
403 restoreState();
404 /* here the data to send is in the next nodes buffers already */
406 /* sendMoreData tracks the offset as well.
407 * Force it back to zero */
408 reqofs = 0;
409 StoreIOBuffer tempresult (reqsize, reqofs, next()->readBuffer.data);
410 sendMoreData(tempresult);
411}
412
413/* This is the workhorse of the HandleIMSReply callback.
414 *
415 * It is called when we've got data back from the origin following our
416 * IMS request to revalidate a stale entry.
417 */
418void
420{
421 if (deleting)
422 return;
423
424 debugs(88, 3, http->storeEntry()->url() << ", " << (long unsigned) result.length << " bytes");
425
426 if (http->storeEntry() == nullptr)
427 return;
428
430 return;
431
433 debugs(88, 3, "CF slave hit private non-shareable " << *http->storeEntry() << ". MISS");
434 // restore context to meet processMiss() expectations
435 restoreState();
437 processMiss();
438 return;
439 }
440
441 /* update size of the request */
442 reqsize = result.length + reqofs;
443
444 // request to origin was aborted
446 debugs(88, 3, "request to origin aborted '" << http->storeEntry()->url() << "', sending old entry to client");
449 return;
450 }
451
452 const auto oldStatus = old_entry->mem().freshestReply().sline.status();
453 const auto &new_rep = http->storeEntry()->mem().freshestReply();
454 const auto status = new_rep.sline.status();
455
456 // XXX: Disregard stale incomplete (i.e. still being written) borrowed (i.e.
457 // not caused by our request) IMS responses. That new_rep may be very old!
458
459 // origin replied 304
460 if (status == Http::scNotModified) {
462 http->request->flags.staleIfHit = false; // old_entry is no longer stale
463
464 // TODO: The update may not be instantaneous. Should we wait for its
465 // completion to avoid spawning too much client-disassociated work?
467
468 // if client sent IMS
470 // forward the 304 from origin
471 debugs(88, 3, "origin replied 304, revalidated existing entry and forwarding 304 to client");
473 return;
474 }
475
476 // send existing entry, it's still valid
477 debugs(88, 3, "origin replied 304, revalidated existing entry and sending " << oldStatus << " to client");
479 return;
480 }
481
482 // origin replied with a non-error code
483 if (status > Http::scNone && status < Http::scInternalServerError) {
484 // RFC 9111 section 4:
485 // "When more than one suitable response is stored,
486 // a cache MUST use the most recent one
487 // (as determined by the Date header field)."
488 if (new_rep.olderThan(&old_entry->mem().freshestReply())) {
489 http->al->cache.code.err.ignored = true;
490 debugs(88, 3, "origin replied " << status << " but with an older date header, sending old entry (" << oldStatus << ") to client");
492 return;
493 }
494
496 debugs(88, 3, "origin replied " << status << ", forwarding to client");
498 return;
499 }
500
501 // origin replied with an error
504 debugs(88, 3, "origin replied with error " << status << ", forwarding to client due to fail_on_validation_err");
506 return;
507 }
508
509 // ignore and let client have old entry
511 debugs(88, 3, "origin replied with error " << status << ", sending old entry (" << oldStatus << ") to client");
513}
514
517
525void
527{
528 clientReplyContext *context = (clientReplyContext *)data;
529 context->cacheHit(result);
530}
531
535void
537{
539 if (deleting) {
540 debugs(88, 3, "HIT object being deleted. Ignore the HIT.");
541 return;
542 }
543
544 StoreEntry *e = http->storeEntry();
545
547
548 debugs(88, 3, "clientCacheHit: " << http->uri << ", " << result.length << " bytes");
549
550 if (http->storeEntry() == nullptr) {
551 debugs(88, 3, "clientCacheHit: request aborted");
552 return;
553 } else if (result.flags.error) {
554 /* swap in failure */
555 debugs(88, 3, "clientCacheHit: swapin failure for " << http->uri);
558 processMiss();
559 return;
560 }
561
562 // The previously identified hit suddenly became unshareable!
563 // This is common for collapsed forwarding slaves but might also
564 // happen to regular hits because we are called asynchronously.
565 if (!e->mayStartHitting()) {
566 debugs(88, 3, "unshareable " << *e << ". MISS");
568 processMiss();
569 return;
570 }
571
572 if (result.length == 0) {
573 debugs(88, 5, "store IO buffer has no content. MISS");
574 /* the store couldn't get enough data from the file for us to id the
575 * object
576 */
577 /* treat as a miss */
579 processMiss();
580 return;
581 }
582
584 /* update size of the request */
585 reqsize = result.length + reqofs;
586
587 /*
588 * Got the headers, now grok them
589 */
591
592 if (http->request->storeId().cmp(e->mem_obj->storeId()) != 0) {
593 debugs(33, DBG_IMPORTANT, "clientProcessHit: URL mismatch, '" << e->mem_obj->storeId() << "' != '" << http->request->storeId() << "'");
594 http->updateLoggingTags(LOG_TCP_MISS); // we lack a more precise LOG_*_MISS code
595 processMiss();
596 return;
597 }
598
599 switch (varyEvaluateMatch(e, r)) {
600
601 case VARY_NONE:
602 /* No variance detected. Continue as normal */
603 break;
604
605 case VARY_MATCH:
606 /* This is the correct entity for this request. Continue */
607 debugs(88, 2, "clientProcessHit: Vary MATCH!");
608 break;
609
610 case VARY_OTHER:
611 /* This is not the correct entity for this request. We need
612 * to requery the cache.
613 */
615 e = nullptr;
616 /* Note: varyEvalyateMatch updates the request with vary information
617 * so we only get here once. (it also takes care of cancelling loops)
618 */
619 debugs(88, 2, "clientProcessHit: Vary detected!");
621 return;
622
623 case VARY_CANCEL:
624 /* varyEvaluateMatch found a object loop. Process as miss */
625 debugs(88, DBG_IMPORTANT, "clientProcessHit: Vary object loop!");
626 http->updateLoggingTags(LOG_TCP_MISS); // we lack a more precise LOG_*_MISS code
627 processMiss();
628 return;
629 }
630
631 if (r->method == Http::METHOD_PURGE) {
632 debugs(88, 5, "PURGE gets a HIT");
634 e = nullptr;
635 purgeRequest();
636 return;
637 }
638
639 if (e->checkNegativeHit() && !r->flags.noCacheHack()) {
640 debugs(88, 5, "negative-HIT");
642 sendMoreData(result);
643 return;
644 } else if (blockedHit()) {
645 debugs(88, 5, "send_hit forces a MISS");
647 processMiss();
648 return;
649 } else if (!http->flags.internal && refreshCheckHTTP(e, r)) {
650 debugs(88, 5, "clientCacheHit: in refreshCheck() block");
651 /*
652 * We hold a stale copy; it needs to be validated
653 */
654 /*
655 * The 'needValidation' flag is used to prevent forwarding
656 * loops between siblings. If our copy of the object is stale,
657 * then we should probably only use parents for the validation
658 * request. Otherwise two siblings could generate a loop if
659 * both have a stale version of the object.
660 */
661 r->flags.needValidation = true;
662
663 if (e->lastModified() < 0) {
664 debugs(88, 3, "validate HIT object? NO. Can't calculate entry modification time. Do MISS.");
665 /*
666 * We cannot revalidate entries without knowing their
667 * modification time.
668 * XXX: BUG 1890 objects without Date do not get one added.
669 */
671 processMiss();
672 } else if (r->flags.noCache) {
673 debugs(88, 3, "validate HIT object? NO. Client sent CC:no-cache. Do CLIENT_REFRESH_MISS");
674 /*
675 * This did not match a refresh pattern that overrides no-cache
676 * we should honour the client no-cache header.
677 */
679 processMiss();
680 } else if (r->url.getScheme() == AnyP::PROTO_HTTP || r->url.getScheme() == AnyP::PROTO_HTTPS) {
681 debugs(88, 3, "validate HIT object? YES.");
682 /*
683 * Object needs to be revalidated
684 * XXX This could apply to FTP as well, if Last-Modified is known.
685 */
687 } else {
688 debugs(88, 3, "validate HIT object? NO. Client protocol non-HTTP. Do MISS.");
689 /*
690 * We don't know how to re-validate other protocols. Handle
691 * them as if the object has expired.
692 */
694 processMiss();
695 }
696 return;
697 } else if (r->conditional()) {
698 debugs(88, 5, "conditional HIT");
699 if (processConditional())
700 return;
701 }
702
703 /*
704 * plain ol' cache hit
705 */
706 debugs(88, 5, "plain old HIT");
707
708#if USE_DELAY_POOLS
709 if (e->store_status != STORE_OK)
711 else
712#endif
713 if (e->mem_status == IN_MEMORY)
715 else if (Config.onoff.offline)
717
718 sendMoreData(result);
719}
720
724void
726{
727 char *url = http->uri;
729 ErrorState *err = nullptr;
730 debugs(88, 4, r->method << ' ' << url);
731
736 if (http->storeEntry()) {
738 debugs(88, DBG_CRITICAL, "clientProcessMiss: miss on a special object (" << url << ").");
739 debugs(88, DBG_CRITICAL, "\tlog_type = " << http->loggingTags().c_str());
740 http->storeEntry()->dump(1);
741 }
742
744 }
745
747 if (r->method == Http::METHOD_PURGE) {
748 purgeRequest();
749 return;
750 }
751
753 if (r->method == Http::METHOD_OTHER) {
755 }
756
758 if (http->onlyIfCached()) {
760 return;
761 }
762
764 if (r->flags.loopDetected) {
770 return;
771 } else {
772 assert(http->out.offset == 0);
775
776 if (http->redirect.status) {
777 const HttpReplyPointer rep(new HttpReply);
783 return;
784 }
785
787
788 Comm::ConnectionPointer conn = http->getConn() != nullptr ? http->getConn()->clientConnection : nullptr;
791 }
792}
793
800void
802{
803 debugs(88, 4, http->request->method << ' ' << http->uri);
806 http->getConn(), http->request, http->al);
808 startError(err);
809}
810
812bool
814{
815 StoreEntry *const e = http->storeEntry();
816
817 const auto replyStatusCode = e->mem().baseReply().sline.status();
818 if (replyStatusCode != Http::scOkay) {
819 debugs(88, 4, "miss because " << replyStatusCode << " != 200");
821 processMiss();
822 return true;
823 }
824
825 HttpRequest &r = *http->request;
826
828 // RFC 2616: reply with 412 Precondition Failed if If-Match did not match
830 return true;
831 }
832
834 // RFC 7232: If-None-Match recipient MUST ignore IMS
835 r.flags.ims = false;
836 r.ims = -1;
837 r.imslen = 0;
839
840 if (e->hasIfNoneMatchEtag(r)) {
842 return true;
843 }
844
845 // None-Match is true (no ETag matched); treat as an unconditional hit
846 return false;
847 }
848
849 if (r.flags.ims) {
850 // handle If-Modified-Since requests from the client
851 if (e->modifiedSince(r.ims, r.imslen)) {
852 // Modified-Since is true; treat as an unconditional hit
853 return false;
854
855 } else {
856 // otherwise reply with 304 Not Modified
858 }
859 return true;
860 }
861
862 return false;
863}
864
866bool
868{
870 return false; // hits are not blocked by default
871
872 if (http->flags.internal)
873 return false; // internal content "hits" cannot be blocked
874
875 const auto &rep = http->storeEntry()->mem().freshestReply();
876 {
877 std::unique_ptr<ACLFilledChecklist> chl(clientAclChecklistCreate(Config.accessList.sendHit, http));
878 chl->reply = const_cast<HttpReply*>(&rep); // ACLChecklist API bug
879 HTTPMSGLOCK(chl->reply);
880 return !chl->fastCheck().allowed(); // when in doubt, block
881 }
882}
883
884// Purges all entries with a given url
885// TODO: move to SideAgent parent, when we have one
886/*
887 * We probably cannot purge Vary-affected responses because their MD5
888 * keys depend on vary headers.
889 */
890void
891purgeEntriesByUrl(HttpRequest * req, const char *url)
892{
894 if (m.respMaybeCacheable()) {
895 const cache_key *key = storeKeyPublic(url, m);
896 debugs(88, 5, m << ' ' << url << ' ' << storeKeyText(key));
897#if USE_HTCP
899#else
900 (void)req;
901#endif
903 }
904 }
905}
906
907void
909{
910 // XXX: performance regression, c_str() reallocates
913}
914
915LogTags *
917{
918 // XXX: clientReplyContext code assumes that http cbdata is always valid.
919 // TODO: Either add cbdataReferenceValid(http) checks in all the relevant
920 // places, like this one, or remove cbdata protection of the http member.
921 return &http->al->cache.code;
922}
923
924void
926{
927 debugs(88, 3, "Config2.onoff.enable_purge = " <<
929
933 http->getConn(), http->request, http->al);
934 startError(err);
935 return;
936 }
937
938 /* Release both IP cache */
940
941 // TODO: can we use purgeAllCached() here instead?
942 purgeDoPurge();
943}
944
945void
947{
948 auto firstFound = false;
950 // special entries are only METHOD_GET entries without variance
951 if (EBIT_TEST(entry->flags, ENTRY_SPECIAL)) {
953 const auto err = clientBuildError(ERR_ACCESS_DENIED, Http::scForbidden, nullptr,
954 http->getConn(), http->request, http->al);
955 startError(err);
956 entry->abandon(__FUNCTION__);
957 return;
958 }
959 firstFound = true;
960 if (!purgeEntry(*entry, Http::METHOD_GET))
961 return;
962 }
963
965
967 if (!purgeEntry(*entry, Http::METHOD_HEAD))
968 return;
969 }
970
971 /* And for Vary, release the base URI if none of the headers was included in the request */
973 && http->request->vary_headers.find('=') != SBuf::npos) {
974 // XXX: performance regression, c_str() reallocates
976
977 if (const auto entry = storeGetPublic(tmp.c_str(), Http::METHOD_GET)) {
978 if (!purgeEntry(*entry, Http::METHOD_GET, "Vary "))
979 return;
980 }
981
982 if (const auto entry = storeGetPublic(tmp.c_str(), Http::METHOD_HEAD)) {
983 if (!purgeEntry(*entry, Http::METHOD_HEAD, "Vary "))
984 return;
985 }
986 }
987
990
991 /*
992 * Make a new entry to hold the reply to be written
993 * to the client.
994 */
995 /* TODO: This doesn't need to go through the store. Simply
996 * push down the client chain
997 */
999
1001
1002 const HttpReplyPointer rep(new HttpReply);
1003 rep->setHeaders(purgeStatus, nullptr, nullptr, 0, 0, -1);
1005 http->storeEntry()->complete();
1006}
1007
1008bool
1009clientReplyContext::purgeEntry(StoreEntry &entry, const Http::MethodType methodType, const char *descriptionPrefix)
1010{
1011 debugs(88, 4, descriptionPrefix << Http::MethodStr(methodType) << " '" << entry.url() << "'" );
1012#if USE_HTCP
1014#endif
1015 entry.release(true);
1017 return true;
1018}
1019
1020void
1022{
1023 clientStreamNode *nextNode = (clientStreamNode *)node->node.next->data;
1024 StoreIOBuffer localTempBuffer;
1026 localTempBuffer.offset = nextNode->readBuffer.offset + headers_sz;
1027 localTempBuffer.length = nextNode->readBuffer.length;
1028 localTempBuffer.data = nextNode->readBuffer.data;
1030 localTempBuffer, SendMoreData, this);
1032 http->storeEntry()->buffer();
1033 const HttpReplyPointer rep(new HttpReply);
1034 rep->setHeaders(Http::scOkay, nullptr, "text/plain", http->request->prefixLen(), 0, squid_curtime);
1037 http->storeEntry()->complete();
1038}
1039
1040#define SENDING_BODY 0
1041#define SENDING_HDRSONLY 1
1042int
1044{
1045 StoreEntry *entry = http->storeEntry();
1046
1047 if (entry == nullptr)
1048 return 0;
1049
1050 /*
1051 * For now, 'done_copying' is used for special cases like
1052 * Range and HEAD requests.
1053 */
1054 if (http->flags.done_copying)
1055 return 1;
1056
1058 // last-chunk was not sent
1059 return 0;
1060 }
1061
1062 /*
1063 * Handle STORE_OK objects.
1064 * objectLen(entry) will be set proprely.
1065 * RC: Does objectLen(entry) include the Headers?
1066 * RC: Yes.
1067 */
1068 if (entry->store_status == STORE_OK) {
1069 return storeOKTransferDone();
1070 } else {
1071 return storeNotOKTransferDone();
1072 }
1073}
1074
1075int
1077{
1078 assert(http->storeEntry()->objectLen() >= 0);
1080 if (http->out.offset >= http->storeEntry()->objectLen() - headers_sz) {
1081 debugs(88,3, "storeOKTransferDone " <<
1082 " out.offset=" << http->out.offset <<
1083 " objectLen()=" << http->storeEntry()->objectLen() <<
1084 " headers_sz=" << headers_sz);
1085 return 1;
1086 }
1087
1088 return 0;
1089}
1090
1091int
1093{
1094 /*
1095 * Now, handle STORE_PENDING objects
1096 */
1097 MemObject *mem = http->storeEntry()->mem_obj;
1098 assert(mem != nullptr);
1099 assert(http->request != nullptr);
1100
1101 /* mem->reply was wrong because it uses the UPSTREAM header length!!! */
1102 if (headers_sz == 0)
1103 /* haven't found end of headers yet */
1104 return 0;
1105
1106 // TODO: Use MemObject::expectedReplySize(method) after resolving XXX below.
1107 const auto expectedBodySize = mem->baseReply().content_length;
1108
1109 // XXX: The code below talks about sending data, and checks stats about
1110 // bytes written to the client connection, but this method must determine
1111 // whether we are done _receiving_ data from Store. This code should work OK
1112 // when expectedBodySize is unknown or matches written data, but it may
1113 // malfunction when we are writing ranges while receiving a full response.
1114
1115 /*
1116 * Figure out how much data we are supposed to send.
1117 * If we are sending a body and we don't have a content-length,
1118 * then we must wait for the object to become STORE_OK.
1119 */
1120 if (expectedBodySize < 0)
1121 return 0;
1122
1123 const uint64_t expectedLength = expectedBodySize + http->out.headers_sz;
1124
1125 if (http->out.size < expectedLength)
1126 return 0;
1127 else {
1128 debugs(88,3, "storeNotOKTransferDone " <<
1129 " out.size=" << http->out.size <<
1130 " expectedLength=" << expectedLength);
1131 return 1;
1132 }
1133}
1134
1135/* Preconditions:
1136 * *http is a valid structure.
1137 * fd is either -1, or an open fd.
1138 *
1139 * TODO: enumify this
1140 *
1141 * This function is used by any http request sink, to determine the status
1142 * of the object.
1143 */
1146{
1147 clientReplyContext *context = dynamic_cast<clientReplyContext *>(aNode->data.getRaw());
1148 assert (context);
1149 assert (context->http == http);
1150 return context->replyStatus();
1151}
1152
1155{
1156 int done;
1157 /* Here because lower nodes don't need it */
1158
1159 if (http->storeEntry() == nullptr) {
1160 debugs(88, 5, "clientReplyStatus: no storeEntry");
1161 return STREAM_FAILED; /* yuck, but what can we do? */
1162 }
1163
1165 /* TODO: Could upstream read errors (result.flags.error) be
1166 * lost, and result in undersize requests being considered
1167 * complete. Should we tcp reset such connections ?
1168 */
1169 debugs(88, 5, "clientReplyStatus: aborted storeEntry");
1170 return STREAM_FAILED;
1171 }
1172
1173 if ((done = checkTransferDone()) != 0 || flags.complete) {
1174 debugs(88, 5, "clientReplyStatus: transfer is DONE: " << done << flags.complete);
1175 /* Ok we're finished, but how? */
1176
1178 debugs(88, 5, "clientReplyStatus: truncated response body");
1180 }
1181
1182 if (!done) {
1183 debugs(88, 5, "clientReplyStatus: closing, !done, but read 0 bytes");
1184 return STREAM_FAILED;
1185 }
1186
1187 // TODO: See also (and unify with) storeNotOKTransferDone() checks.
1188 const int64_t expectedBodySize =
1190 if (expectedBodySize >= 0 && !http->gotEnough()) {
1191 debugs(88, 5, "clientReplyStatus: client didn't get all it expected");
1193 }
1194
1195 debugs(88, 5, "clientReplyStatus: stream complete; keepalive=" <<
1197 return STREAM_COMPLETE;
1198 }
1199
1200 // XXX: Should this be checked earlier? We could return above w/o checking.
1202 /* 4096 is a margin for the HTTP headers included in out.offset */
1203 debugs(88, 5, "clientReplyStatus: client reply body is too large");
1204 return STREAM_FAILED;
1205 }
1206
1207 return STREAM_NONE;
1208}
1209
1210/* Responses with no body will not have a content-type header,
1211 * which breaks the rep_mime_type acl, which
1212 * coincidentally, is the most common acl for reply access lists.
1213 * A better long term fix for this is to allow acl matches on the various
1214 * status codes, and then supply a default ruleset that puts these
1215 * codes before any user defines access entries. That way the user
1216 * can choose to block these responses where appropriate, but won't get
1217 * mysterious breakages.
1218 */
1219bool
1221{
1222 bool result;
1223
1224 switch (sline) {
1225
1226 case Http::scContinue:
1227
1229
1230 case Http::scProcessing:
1231
1232 case Http::scNoContent:
1233
1235 result = true;
1236 break;
1237
1238 default:
1239 result = false;
1240 }
1241
1242 return result;
1243}
1244
1252void
1254{
1255 HttpHeader *hdr = &reply->header;
1256 const bool is_hit = http->loggingTags().isTcpHit();
1258
1259 if (is_hit || collapsedRevalidation == crSlave)
1261 // TODO: RFC 2965 : Must honour Cache-Control: no-cache="set-cookie2" and remove header.
1262
1263 // if there is not configured a peer proxy with login=PASS or login=PASSTHRU option enabled
1264 // remove the Proxy-Authenticate header
1265 if ( !request->peer_login || (strcmp(request->peer_login,"PASS") != 0 && strcmp(request->peer_login,"PASSTHRU") != 0)) {
1266#if USE_ADAPTATION
1267 // but allow adaptation services to authenticate clients
1268 // via request satisfaction
1270#endif
1272 }
1273
1275 // paranoid: ContentLengthInterpreter has cleaned non-generated replies
1277
1278 // if (request->range)
1279 // clientBuildRangeHeader(http, reply);
1280
1281 /*
1282 * Add a estimated Age header on cache hits.
1283 */
1284 if (is_hit) {
1285 /*
1286 * Remove any existing Age header sent by upstream caches
1287 * (note that the existing header is passed along unmodified
1288 * on cache misses)
1289 */
1291 /*
1292 * This adds the calculated object age. Note that the details of the
1293 * age calculation is performed by adjusting the timestamp in
1294 * StoreEntry::timestampsSet(), not here.
1295 */
1299 } else if (http->getConn() && http->getConn()->port->actAsOrigin) {
1300 // Swap the Date: header to current time if we are simulating an origin
1302 if (h)
1303 hdr->putExt("X-Origin-Date", h->value.termedBuf());
1307 if (h && http->storeEntry()->expires >= 0) {
1308 hdr->putExt("X-Origin-Expires", h->value.termedBuf());
1311 }
1313 // put X-Cache-Age: instead of Age:
1314 char age[64];
1315 snprintf(age, sizeof(age), "%" PRId64, static_cast<int64_t>(squid_curtime - http->storeEntry()->timestamp));
1316 hdr->putExt("X-Cache-Age", age);
1317 }
1318 } else if (http->storeEntry()->timestamp <= squid_curtime) {
1321 }
1322 }
1323
1324 /* RFC 2616: Section 14.18
1325 *
1326 * Add a Date: header if missing.
1327 * We have access to a clock therefore are required to amend any shortcoming in servers.
1328 *
1329 * NP: done after Age: to prevent ENTRY_SPECIAL double-handling this header.
1330 */
1331 if ( !hdr->has(Http::HdrType::DATE) ) {
1332 if (!http->storeEntry())
1334 else if (http->storeEntry()->timestamp > 0)
1336 else {
1337 debugs(88, DBG_IMPORTANT, "ERROR: Squid BUG #3279: HTTP reply without Date:");
1338 /* dump something useful about the problem */
1340 }
1341 }
1342
1343 /* Filter unproxyable authentication types */
1347 HttpHeaderEntry *e;
1348
1349 int connection_auth_blocked = 0;
1350 while ((e = hdr->getEntry(&pos))) {
1352 const char *value = e->value.rawBuf();
1353
1354 if ((strncasecmp(value, "NTLM", 4) == 0 &&
1355 (value[4] == '\0' || value[4] == ' '))
1356 ||
1357 (strncasecmp(value, "Negotiate", 9) == 0 &&
1358 (value[9] == '\0' || value[9] == ' '))
1359 ||
1360 (strncasecmp(value, "Kerberos", 8) == 0 &&
1361 (value[8] == '\0' || value[8] == ' '))) {
1362 if (request->flags.connectionAuthDisabled) {
1363 hdr->delAt(pos, connection_auth_blocked);
1364 continue;
1365 }
1366 request->flags.mustKeepalive = true;
1367 if (!request->flags.accelerated && !request->flags.intercepted) {
1368 httpHeaderPutStrf(hdr, Http::HdrType::PROXY_SUPPORT, "Session-Based-Authentication");
1369 /*
1370 We send "Connection: Proxy-Support" header to mark
1371 Proxy-Support as a hop-by-hop header for intermediaries that do not
1372 understand the semantics of this header. The RFC should have included
1373 this recommendation.
1374 */
1375 httpHeaderPutStrf(hdr, Http::HdrType::CONNECTION, "Proxy-support");
1376 }
1377 break;
1378 }
1379 }
1380 }
1381
1382 if (connection_auth_blocked)
1383 hdr->refreshMask();
1384 }
1385
1386#if USE_AUTH
1387 /* Handle authentication headers */
1391 ) {
1392 /* Add authentication header */
1393 /* TODO: alter errorstate to be accel on|off aware. The 0 on the next line
1394 * depends on authenticate behaviour: all schemes to date send no extra
1395 * data on 407/401 responses, and do not check the accel state on 401/407
1396 * responses
1397 */
1398 Auth::UserRequest::AddReplyAuthHeader(reply, request->auth_user_request, request, 0, 1);
1399 } else if (request->auth_user_request != nullptr)
1401#endif
1402
1403 SBuf cacheStatus(uniqueHostname());
1404 if (const auto hitOrFwd = http->loggingTags().cacheStatusSource())
1405 cacheStatus.append(hitOrFwd);
1406 if (firstStoreLookup_) {
1407 cacheStatus.append(";detail=");
1408 cacheStatus.append(firstStoreLookup_);
1409 }
1410 // TODO: Remove c_str() after converting HttpHeaderEntry::value to SBuf
1411 hdr->putStr(Http::HdrType::CACHE_STATUS, cacheStatus.c_str());
1412
1413 const bool maySendChunkedReply = !request->multipartRangeRequest() &&
1414 reply->sline.version.protocol == AnyP::PROTO_HTTP && // response is HTTP
1415 (request->http_ver >= Http::ProtocolVersion(1,1));
1416
1417 /* Check whether we should send keep-alive */
1418 if (!Config.onoff.error_pconns && reply->sline.status() >= 400 && !request->flags.mustKeepalive) {
1419 debugs(33, 3, "clientBuildReplyHeader: Error, don't keep-alive");
1420 request->flags.proxyKeepalive = false;
1421 } else if (!Config.onoff.client_pconns && !request->flags.mustKeepalive) {
1422 debugs(33, 2, "clientBuildReplyHeader: Connection Keep-Alive not requested by admin or client");
1423 request->flags.proxyKeepalive = false;
1424 } else if (request->flags.proxyKeepalive && shutting_down) {
1425 debugs(88, 3, "clientBuildReplyHeader: Shutting down, don't keep-alive.");
1426 request->flags.proxyKeepalive = false;
1427 } else if (request->flags.connectionAuth && !reply->keep_alive) {
1428 debugs(33, 2, "clientBuildReplyHeader: Connection oriented auth but server side non-persistent");
1429 request->flags.proxyKeepalive = false;
1430 } else if (reply->bodySize(request->method) < 0 && !maySendChunkedReply) {
1431 debugs(88, 3, "clientBuildReplyHeader: can't keep-alive, unknown body size" );
1432 request->flags.proxyKeepalive = false;
1433 } else if (fdUsageHigh()&& !request->flags.mustKeepalive) {
1434 debugs(88, 3, "clientBuildReplyHeader: Not many unused FDs, can't keep-alive");
1435 request->flags.proxyKeepalive = false;
1436 } else if (request->flags.sslBumped && !reply->persistent()) {
1437 // We do not really have to close, but we pretend we are a tunnel.
1438 debugs(88, 3, "clientBuildReplyHeader: bumped reply forces close");
1439 request->flags.proxyKeepalive = false;
1440 } else if (request->pinnedConnection() && !reply->persistent()) {
1441 // The peer wants to close the pinned connection
1442 debugs(88, 3, "pinned reply forces close");
1443 request->flags.proxyKeepalive = false;
1444 } else if (http->getConn()) {
1446 if (!Comm::IsConnOpen(conn->port->listenConn)) {
1447 // The listening port closed because of a reconfigure
1448 debugs(88, 3, "listening port closed");
1449 request->flags.proxyKeepalive = false;
1450 }
1451 }
1452
1453 // Decide if we send chunked reply
1454 if (maySendChunkedReply && reply->bodySize(request->method) < 0) {
1455 debugs(88, 3, "clientBuildReplyHeader: chunked reply");
1456 request->flags.chunkedReply = true;
1458 }
1459
1460 hdr->addVia(reply->sline.version);
1461
1462 /* Signal keep-alive or close explicitly */
1463 hdr->putStr(Http::HdrType::CONNECTION, request->flags.proxyKeepalive ? "keep-alive" : "close");
1464
1465#if ADD_X_REQUEST_URI
1466 /*
1467 * Knowing the URI of the request is useful when debugging persistent
1468 * connections in a client; we cannot guarantee the order of http headers,
1469 * but X-Request-URI is likely to be the very last header to ease use from a
1470 * debugger [hdr->entries.count-1].
1471 */
1473 http->memOjbect()->url ? http->memObject()->url : http->uri);
1474
1475#endif
1476
1477 /* Surrogate-Control requires Surrogate-Capability from upstream to pass on */
1479 if (!request->header.has(Http::HdrType::SURROGATE_CAPABILITY)) {
1481 }
1482 /* TODO: else case: drop any controls intended specifically for our surrogate ID */
1483 }
1484
1486}
1487
1488void
1490{
1491 assert(reply == nullptr);
1492
1495
1496 http->al->reply = reply;
1497
1499 /* RFC 2616 requires us to advertise our version (but only on real HTTP traffic) */
1501 }
1502
1503 /* do header conversions */
1505}
1506
1510void
1512{
1513 StoreEntry *e = http->storeEntry();
1514 assert(e); // or we are not dealing with a hit
1515 // We probably have not locked the entry earlier, unfortunately. We lock it
1516 // now so that we can unlock two lines later (and trigger cleanup).
1517 // Ideally, ClientHttpRequest::storeEntry() should lock/unlock, but it is
1518 // used so inconsistently that simply adding locking there leads to bugs.
1519 e->lock("clientReplyContext::forgetHit");
1520 http->storeEntry(nullptr);
1521 e->unlock("clientReplyContext::forgetHit"); // may delete e
1522}
1523
1524void
1526{
1527 HttpRequest *r = http->request;
1528
1529 // client sent CC:no-cache or some other condition has been
1530 // encountered which prevents delivering a public/cached object.
1531 if (!r->flags.noCache || r->flags.internal) {
1532 const auto e = storeGetPublicByRequest(r);
1534 } else {
1535 // "external" no-cache requests skip Store lookups
1536 identifyFoundObject(nullptr, "no-cache");
1537 }
1538}
1539
1544void
1546{
1547 detailStoreLookup(detail);
1548
1549 HttpRequest *r = http->request;
1550 http->storeEntry(newEntry);
1551 const auto e = http->storeEntry();
1552
1553 /* Release IP-cache entries on reload */
1557 if (r->flags.noCache || r->flags.noCacheHack())
1559
1560 if (!e) {
1562 debugs(85, 3, "StoreEntry is NULL - MISS");
1564 doGetMoreData();
1565 return;
1566 }
1567
1568 if (Config.onoff.offline) {
1570 debugs(85, 3, "offline HIT " << *e);
1572 doGetMoreData();
1573 return;
1574 }
1575
1576 if (http->redirect.status) {
1578 debugs(85, 3, "REDIRECT status forced StoreEntry to NULL (no body on 3XX responses) " << *e);
1579 forgetHit();
1581 doGetMoreData();
1582 return;
1583 }
1584
1585 if (!e->validToSend()) {
1586 debugs(85, 3, "!storeEntryValidToSend MISS " << *e);
1587 forgetHit();
1589 doGetMoreData();
1590 return;
1591 }
1592
1593 if (EBIT_TEST(e->flags, ENTRY_SPECIAL)) {
1594 /* \li Special entries are always hits, no matter what the client says */
1595 debugs(85, 3, "ENTRY_SPECIAL HIT " << *e);
1597 doGetMoreData();
1598 return;
1599 }
1600
1601 if (r->flags.noCache) {
1602 debugs(85, 3, "no-cache REFRESH MISS " << *e);
1603 forgetHit();
1605 doGetMoreData();
1606 return;
1607 }
1608
1609 if (e->hittingRequiresCollapsing() && !startCollapsingOn(*e, false)) {
1610 debugs(85, 3, "prohibited CF MISS " << *e);
1611 forgetHit();
1613 doGetMoreData();
1614 return;
1615 }
1616
1617 debugs(85, 3, "default HIT " << *e);
1619 doGetMoreData();
1620}
1621
1623void
1625{
1626 if (!firstStoreLookup_) {
1627 debugs(85, 7, detail);
1628 firstStoreLookup_ = detail;
1629 } else {
1630 debugs(85, 7, "ignores " << detail << " after " << firstStoreLookup_);
1631 }
1632}
1633
1643void
1645{
1646 /* Test preconditions */
1647 assert(aNode != nullptr);
1649 assert(aNode->node.prev == nullptr);
1650 assert(aNode->node.next != nullptr);
1651 clientReplyContext *context = dynamic_cast<clientReplyContext *>(aNode->data.getRaw());
1652 assert (context);
1653 assert(context->http == http);
1654
1655 clientStreamNode *next = ( clientStreamNode *)aNode->node.next->data;
1656
1657 if (!context->ourNode)
1658 context->ourNode = aNode;
1659
1660 /* no cbdatareference, this is only used once, and safely */
1661 if (context->flags.storelogiccomplete) {
1662 StoreIOBuffer tempBuffer;
1663 tempBuffer.offset = next->readBuffer.offset + context->headers_sz;
1664 tempBuffer.length = next->readBuffer.length;
1665 tempBuffer.data = next->readBuffer.data;
1666
1667 storeClientCopy(context->sc, http->storeEntry(),
1668 tempBuffer, clientReplyContext::SendMoreData, context);
1669 return;
1670 }
1671
1672 if (context->http->request->method == Http::METHOD_PURGE) {
1673 context->purgeRequest();
1674 return;
1675 }
1676
1677 // OPTIONS with Max-Forwards:0 handled in clientProcessRequest()
1678
1679 if (context->http->request->method == Http::METHOD_TRACE) {
1681 context->traceReply(aNode);
1682 return;
1683 }
1684
1685 /* continue forwarding, not finished yet. */
1687
1688 context->doGetMoreData();
1689 } else
1690 context->identifyStoreObject();
1691}
1692
1693void
1695{
1696 /* We still have to do store logic processing - vary, cache hit etc */
1697 if (http->storeEntry() != nullptr) {
1698 /* someone found the object in the cache for us */
1699 StoreIOBuffer localTempBuffer;
1700
1701 http->storeEntry()->lock("clientReplyContext::doGetMoreData");
1702
1704
1706#if USE_DELAY_POOLS
1708#endif
1709
1711 reqofs = 0;
1712 /* guarantee nothing has been sent yet! */
1713 assert(http->out.size == 0);
1714 assert(http->out.offset == 0);
1715
1716 if (ConnStateData *conn = http->getConn()) {
1717 if (Ip::Qos::TheConfig.isHitTosActive()) {
1718 Ip::Qos::doTosLocalHit(conn->clientConnection);
1719 }
1720
1721 if (Ip::Qos::TheConfig.isHitNfmarkActive()) {
1722 Ip::Qos::doNfmarkLocalHit(conn->clientConnection);
1723 }
1724 }
1725
1726 localTempBuffer.offset = reqofs;
1727 localTempBuffer.length = getNextNode()->readBuffer.length;
1728 localTempBuffer.data = getNextNode()->readBuffer.data;
1729 storeClientCopy(sc, http->storeEntry(), localTempBuffer, CacheHit, this);
1730 } else {
1731 /* MISS CASE, http->loggingTags() are already set! */
1732 processMiss();
1733 }
1734}
1735
1737void
1739{
1741 clientStreamDetach(node, http);
1742}
1743
1748void
1750{
1751 clientReplyContext *context = static_cast<clientReplyContext *>(data);
1752 context->sendMoreData (result);
1753}
1754
1755void
1757{
1758 /* At least, I think that's what this does */
1761}
1762
1763bool
1764clientReplyContext::errorInStream(StoreIOBuffer const &result, size_t const &sizeToProcess)const
1765{
1766 return /* aborted request */
1768 /* Upstream read error */ (result.flags.error) ||
1769 /* Upstream EOF */ (sizeToProcess == 0);
1770}
1771
1772void
1774{
1780 debugs(88, 5, "A stream error has occurred, marking as complete and sending no data.");
1781 StoreIOBuffer localTempBuffer;
1782 flags.complete = 1;
1783 http->request->flags.streamError = true;
1784 localTempBuffer.flags.error = result.flags.error;
1786 localTempBuffer);
1787}
1788
1789void
1791{
1792 StoreIOBuffer localTempBuffer;
1793
1794 if (result.length == 0) {
1795 debugs(88, 5, "clientReplyContext::pushStreamData: marking request as complete due to 0 length store result");
1796 flags.complete = 1;
1797 }
1798
1799 assert(result.offset - headers_sz == next()->readBuffer.offset);
1800 localTempBuffer.offset = result.offset - headers_sz;
1801 localTempBuffer.length = result.length;
1802
1803 if (localTempBuffer.length)
1804 localTempBuffer.data = source;
1805
1807 localTempBuffer);
1808}
1809
1812{
1814 return getNextNode();
1815}
1816
1817void
1819{
1822 http->getConn(), http->request, http->al);
1825 startError(err);
1826
1827}
1828
1830void
1832{
1834 ErrorState *const err =
1836 nullptr, http->getConn(), http->request, http->al);
1839 startError(err);
1840}
1841
1843void
1845{
1846 StoreEntry *e = http->storeEntry();
1847 const time_t timestamp = e->timestamp;
1848 const auto temprep = e->mem().freshestReply().make304();
1849 // log as TCP_INM_HIT if code 304 generated for
1850 // If-None-Match request
1851 if (!http->request->flags.ims)
1853 else
1857 e = http->storeEntry();
1858 // Copy timestamp from the original entry so the 304
1859 // reply has a meaningful Age: header.
1860 e->timestampsSet();
1861 e->timestamp = timestamp;
1862 e->replaceHttpReply(temprep);
1863 e->complete();
1864 /*
1865 * TODO: why put this in the store and then serialise it and
1866 * then parse it again. Simply mark the request complete in
1867 * our context and write the reply struct to the client side.
1868 */
1870}
1871
1874void
1876{
1880 else
1882}
1883
1884void
1886{
1887 /* NP: this should probably soft-fail to a zero-sized-reply error ?? */
1888 assert(reply);
1889
1896 return;
1897 }
1898
1902 return;
1903 }
1904
1906
1908 if (!Config.accessList.reply) {
1910 return;
1911 }
1912
1914 ACLFilledChecklist *replyChecklist =
1916 replyChecklist->reply = reply;
1917 HTTPMSGLOCK(replyChecklist->reply);
1918 replyChecklist->nonBlockingCheck(ProcessReplyAccessResult, this);
1919}
1920
1921void
1923{
1924 clientReplyContext *me = static_cast<clientReplyContext *>(voidMe);
1926}
1927
1928void
1930{
1931 debugs(88, 2, "The reply for " << http->request->method
1932 << ' ' << http->uri << " is " << accessAllowed << ", because it matched "
1933 << (AclMatchedName ? AclMatchedName : "NO ACL's"));
1934
1935 if (!accessAllowed.allowed()) {
1936 ErrorState *err;
1937 err_type page_id;
1939
1941
1942 if (page_id == ERR_NONE)
1943 page_id = ERR_ACCESS_DENIED;
1944
1945 err = clientBuildError(page_id, Http::scForbidden, nullptr,
1946 http->getConn(), http->request, http->al);
1947
1949
1951
1952 startError(err);
1953
1954 return;
1955 }
1956
1957 /* Ok, the reply is allowed, */
1959
1960 ssize_t body_size = reqofs - reply->hdr_sz;
1961 if (body_size < 0) {
1962 reqofs = reply->hdr_sz;
1963 body_size = 0;
1964 }
1965
1966 debugs(88, 3, "clientReplyContext::sendMoreData: Appending " <<
1967 (int) body_size << " bytes after " << reply->hdr_sz <<
1968 " bytes of headers");
1969
1970#if USE_SQUID_ESI
1971
1975 debugs(88, 2, "Enabling ESI processing for " << http->uri);
1978 }
1979
1980#endif
1981
1983 /* do not forward body for HEAD replies */
1984 body_size = 0;
1985 http->flags.done_copying = true;
1986 flags.complete = 1;
1987 }
1988
1990 flags.headersSent = true;
1991
1992 StoreIOBuffer localTempBuffer;
1993 char *buf = next()->readBuffer.data;
1994 char *body_buf = buf + reply->hdr_sz;
1995
1996 //Server side may disable ranges under some circumstances.
1997
1998 if ((!http->request->range))
1999 next()->readBuffer.offset = 0;
2000
2001 body_buf -= next()->readBuffer.offset;
2002
2003 if (next()->readBuffer.offset != 0) {
2004 if (next()->readBuffer.offset > body_size) {
2005 /* Can't use any of the body we received. send nothing */
2006 localTempBuffer.length = 0;
2007 localTempBuffer.data = nullptr;
2008 } else {
2009 localTempBuffer.length = body_size - next()->readBuffer.offset;
2010 localTempBuffer.data = body_buf + next()->readBuffer.offset;
2011 }
2012 } else {
2013 localTempBuffer.length = body_size;
2014 localTempBuffer.data = body_buf;
2015 }
2016
2017 /* TODO??: move the data in the buffer back by the request header size */
2019 http, reply, localTempBuffer);
2020
2021 return;
2022}
2023
2024void
2026{
2027 if (deleting)
2028 return;
2029
2030 StoreEntry *entry = http->storeEntry();
2031
2032 if (ConnStateData * conn = http->getConn()) {
2033 if (!conn->isOpen()) {
2034 debugs(33,3, "not sending more data to closing connection " << conn->clientConnection);
2035 return;
2036 }
2037 if (conn->pinning.zeroReply) {
2038 debugs(33,3, "not sending more data after a pinned zero reply " << conn->clientConnection);
2039 return;
2040 }
2041
2042 if (reqofs==0 && !http->loggingTags().isTcpHit()) {
2043 if (Ip::Qos::TheConfig.isHitTosActive()) {
2044 Ip::Qos::doTosLocalMiss(conn->clientConnection, http->request->hier.code);
2045 }
2046 if (Ip::Qos::TheConfig.isHitNfmarkActive()) {
2047 Ip::Qos::doNfmarkLocalMiss(conn->clientConnection, http->request->hier.code);
2048 }
2049 }
2050
2051 debugs(88, 5, conn->clientConnection <<
2052 " '" << entry->url() << "'" <<
2053 " out.offset=" << http->out.offset);
2054 }
2055
2056 char *buf = next()->readBuffer.data;
2057
2058 if (buf != result.data) {
2059 /* we've got to copy some data */
2060 assert(result.length <= next()->readBuffer.length);
2061 memcpy(buf, result.data, result.length);
2062 }
2063
2064 /* We've got the final data to start pushing... */
2066
2067 reqofs += result.length;
2068
2070
2071 assert(http->request != nullptr);
2072
2073 /* ESI TODO: remove this assert once everything is stable */
2076
2077 makeThisHead();
2078
2079 debugs(88, 5, "clientReplyContext::sendMoreData: " << http->uri << ", " <<
2080 reqofs << " bytes (" << result.length <<
2081 " new bytes)");
2082
2083 /* update size of the request */
2084 reqsize = reqofs;
2085
2086 if (errorInStream(result, reqofs)) {
2087 sendStreamError(result);
2088 return;
2089 }
2090
2091 if (flags.headersSent) {
2092 pushStreamData (result, buf);
2093 return;
2094 }
2095
2096 cloneReply();
2097
2098#if USE_DELAY_POOLS
2099 if (sc)
2101#endif
2102
2103 holdingBuffer = result;
2105 return;
2106}
2107
2108void
2110{
2111 clientAclChecklistFill(checklist, http);
2112}
2113
2114/* Using this breaks the client layering just a little!
2115 */
2116void
2118{
2119 assert(http != nullptr);
2120 /*
2121 * For erroneous requests, we might not have a h->request,
2122 * so make a fake one.
2123 */
2124
2125 if (http->request == nullptr) {
2126 const auto connManager = http->getConn();
2127 const auto mx = MasterXaction::MakePortful(connManager ? connManager->port : nullptr);
2128 // XXX: These fake URI parameters shadow the real (or error:...) URI.
2129 // TODO: Either always set the request earlier and assert here OR use
2130 // http->uri (converted to Anyp::Uri) to create this catch-all request.
2131 const_cast<HttpRequest *&>(http->request) = new HttpRequest(m, AnyP::PROTO_NONE, "http", null_string, mx);
2133 }
2134
2135 StoreEntry *e = storeCreateEntry(storeId(), http->log_uri, reqFlags, m);
2136
2137 // Make entry collapsible ASAP, to increase collapsing chances for others,
2138 // TODO: every must-revalidate and similar request MUST reach the origin,
2139 // but do we have to prohibit others from collapsing on that request?
2140 if (reqFlags.cachable &&
2141 !reqFlags.needValidation &&
2142 (m == Http::METHOD_GET || m == Http::METHOD_HEAD) &&
2144 // make the entry available for future requests now
2145 (void)Store::Root().allowCollapsing(e, reqFlags, m);
2146 }
2147
2148 sc = storeClientListAdd(e, this);
2149
2150#if USE_DELAY_POOLS
2152#endif
2153
2154 reqofs = 0;
2155
2156 reqsize = 0;
2157
2158 /* I don't think this is actually needed! -- adrian */
2159 /* http->reqbuf = http->norm_reqbuf; */
2160 // assert(http->reqbuf == http->norm_reqbuf);
2161 /* The next line is illegal because we don't know if the client stream
2162 * buffers have been set up
2163 */
2164 // storeClientCopy(http->sc, e, 0, HTTP_REQBUF_SZ, http->reqbuf,
2165 // SendMoreData, this);
2166 /* So, we mark the store logic as complete */
2168
2169 /* and get the caller to request a read, from wherever they are */
2170 /* NOTE: after ANY data flows down the pipe, even one step,
2171 * this function CAN NOT be used to manage errors
2172 */
2173 http->storeEntry(e);
2174}
2175
2176ErrorState *
2177clientBuildError(err_type page_id, Http::StatusCode status, char const *url,
2179{
2180 const auto err = new ErrorState(page_id, status, request, al);
2181 err->src_addr = conn && conn->clientConnection ? conn->clientConnection->remote : Ip::Address::NoAddr();
2182
2183 if (url)
2184 err->url = xstrdup(url);
2185
2186 return err;
2187}
2188
int esiEnableProcessing(HttpReply *rep)
Definition: Esi.cc:2239
CSCB esiProcessStream
CSR esiStreamRead
CSD esiStreamDetach
CSS esiStreamStatus
#define false
Definition: GnuRegex.c:240
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
int storeClientIsThisAClient(store_client *sc, void *someClient)
#define Must(condition)
Definition: TextException.h:71
int conn
the current server connection FD
Definition: Transport.cc:26
#define assert(EX)
Definition: assert.h:19
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:398
#define cbdataReferenceDone(var)
Definition: cbdata.h:350
#define cbdataReference(var)
Definition: cbdata.h:341
#define CBDATA_CLASS_INIT(type)
Definition: cbdata.h:318
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:150
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:99
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
int port
port of pinned connection
Definition: client_side.h:146
static DelayId DelayClient(ClientHttpRequest *, HttpReply *reply=nullptr)
Definition: DelayId.cc:67
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:185
Http::StatusCode httpStatus
Definition: errorpage.h:171
static void Start(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
Initiates request forwarding to a peer or origin server.
Definition: FwdState.cc:360
Http::HdrType id
Definition: HttpHeader.h:63
void removeHopByHopEntries()
Definition: HttpHeader.cc:1707
void putStr(Http::HdrType id, const char *str)
Definition: HttpHeader.cc:1028
void delAt(HttpHeaderPos pos, int &headers_deleted)
Definition: HttpHeader.cc:699
void putInt(Http::HdrType id, int number)
Definition: HttpHeader.cc:1001
int delById(Http::HdrType id)
Definition: HttpHeader.cc:671
void refreshMask()
Definition: HttpHeader.cc:727
HttpHeaderEntry * getEntry(HttpHeaderPos *pos) const
Definition: HttpHeader.cc:588
void addVia(const AnyP::ProtocolVersion &ver, const HttpHeader *from=nullptr)
Definition: HttpHeader.cc:975
int has(Http::HdrType id) const
Definition: HttpHeader.cc:967
int64_t getInt64(Http::HdrType id) const
Definition: HttpHeader.cc:1130
HttpHeaderEntry * findEntry(Http::HdrType id) const
Definition: HttpHeader.cc:607
void putExt(const char *name, const char *value)
Definition: HttpHeader.cc:1109
void putTime(Http::HdrType id, time_t htime)
Definition: HttpHeader.cc:1019
Http::StatusLine sline
Definition: HttpReply.h:56
HttpReply * clone() const
Definition: HttpReply.cc:572
HttpReplyPointer make304() const
Definition: HttpReply.cc:127
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
Definition: HttpReply.cc:167
int64_t bodySize(const HttpRequestMethod &) const
Definition: HttpReply.cc:374
void removeIrrelevantContentLength()
Some response status codes prohibit sending Content-Length (RFC 7230 section 3.3.2).
Definition: HttpReply.cc:607
bool receivedBodyTooLarge(HttpRequest &, int64_t receivedBodySize)
Definition: HttpReply.cc:516
void redirect(Http::StatusCode, const char *)
Definition: HttpReply.cc:202
bool expectedBodyTooLarge(HttpRequest &request)
Definition: HttpReply.cc:524
short int keep_alive
Definition: HttpReply.h:53
bool conditional() const
has at least one recognized If-* header
Definition: HttpRequest.cc:575
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
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
void ignoreRange(const char *reason)
forgets about the cached Range header (for a reason)
Definition: HttpRequest.cc:624
const SBuf storeId()
Definition: HttpRequest.cc:736
void swapOut(StoreEntry *e)
Definition: HttpRequest.cc:334
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:747
bool persistent() const
Definition: Message.cc:247
HttpHeader header
Definition: Message.h:74
int hdr_sz
Definition: Message.h:81
int64_t content_length
Definition: Message.h:83
AnyP::ProtocolVersion version
breakdown of protocol version label: (HTTP/ICY) and (0.9/1.0/1.1)
Definition: StatusLine.h:62
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:67
const char * storeId() const
Definition: MemObject.cc:53
const HttpReply & baseReply() const
Definition: MemObject.h:59
C * getRaw() const
Definition: RefCount.h:80
bool needValidation
Definition: RequestFlags.h:46
bool chunkedReply
Definition: RequestFlags.h:90
bool noCacheHack() const
Definition: RequestFlags.h:124
bool streamError
Definition: RequestFlags.h:92
bool proxyKeepalive
Definition: RequestFlags.h:38
bool failOnValidationError
Definition: RequestFlags.h:48
bool loopDetected
Definition: RequestFlags.h:36
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:98
struct SquidConfig2::@126 onoff
int error_pconns
Definition: SquidConfig.h:304
struct SquidConfig::@111 onoff
acl_access * reply
Definition: SquidConfig.h:377
struct SquidConfig::@112 accessList
AclDenyInfoList * denyInfoList
Definition: SquidConfig.h:406
int client_pconns
Definition: SquidConfig.h:302
int collapsed_forwarding
Definition: SquidConfig.h:321
acl_access * sendHit
Definition: SquidConfig.h:365
bool mayInitiateCollapsing() const
whether Squid configuration allows us to become a CF initiator
Definition: StoreClient.h:45
bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const
Definition: store_client.cc:64
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:1840
virtual void buffer()
Definition: store.cc:1568
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:1556
bool hasIfNoneMatchEtag(const HttpRequest &request) const
has ETag matching at least one of the If-None-Match etags
Definition: store.cc:1847
void dump(int debug_lvl) const
Definition: store.cc:1466
int unlock(const char *context)
Definition: store.cc:442
const char * url() const
Definition: store.cc:1533
void complete()
Definition: store.cc:1004
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:1829
void lastModified(const time_t when)
Definition: Store.h:176
void release(const bool shareable=false)
Definition: store.cc:1119
void lock(const char *context)
Definition: store.cc:418
time_t timestamp
Definition: Store.h:224
bool timestampsSet()
Definition: store.cc:1360
void clearPublicKeyScope()
Definition: store.cc:582
void storeErrorResponse(HttpReply *reply)
Store a prepared error response. MemObject locks the reply object.
Definition: store.cc:1655
bool mayStartHitting() const
Definition: Store.h:288
int checkNegativeHit() const
Definition: store.cc:1273
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
Definition: store.cc:1672
MemObject * mem_obj
Definition: Store.h:221
bool modifiedSince(const time_t ims, const int imslen=-1) const
Definition: store.cc:1803
int64_t objectLen() const
Definition: Store.h:257
store_status_t store_status
Definition: Store.h:244
void releaseRequest(const bool shareable=false)
Definition: store.cc:431
unsigned error
Definition: StoreIOBuffer.h:52
struct StoreIOBuffer::@147 flags
int64_t offset
Definition: StoreIOBuffer.h:55
bool allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &)
tries to make the entry available for collapsing future requests
Definition: Controller.cc:733
static bool SmpAware()
whether there are any SMP-aware storages
Definition: Controller.cc:908
virtual void evictIfFound(const cache_key *) override
Definition: Controller.cc:506
void updateOnNotModified(StoreEntry *old, StoreEntry &e304)
using a 304 response, update the old entry (metadata and reply headers)
Definition: Controller.cc:700
void clean()
Definition: String.cc:118
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
void traceReply(clientStreamNode *node)
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 cacheHit(StoreIOBuffer result)
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
StoreIOBuffer tempBuffer
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 blockedHit() const
whether squid.conf send_hit prevents us from serving this hit
bool errorInStream(StoreIOBuffer const &result, size_t const &sizeToProcess) const
int storeNotOKTransferDone() const
void removeClientStoreReference(store_client **scp, ClientHttpRequest *http)
void pushStreamData(StoreIOBuffer const &result, char *source)
struct clientReplyContext::Flags flags
void processReplyAccessResult(const Acl::Answer &accessAllowed)
const char * firstStoreLookup_
CollapsedRevalidation collapsedRevalidation
char tempbuf[HTTP_REQBUF_SZ]
a temporary buffer if we need working storage
virtual void fillChecklist(ACLFilledChecklist &) const
configure the given checklist (to reflect the current transaction state)
const char * storeLookupString(bool found) const
bool purgeEntry(StoreEntry &, const Http::MethodType, const char *descriptionPrefix="")
clientStreamNode * next() const
void sendMoreData(StoreIOBuffer result)
ClientHttpRequest * http
clientStream_status_t replyStatus()
void removeStoreReference(store_client **scp, StoreEntry **ep)
const char * storeId() const
bool processConditional()
process conditional request from client
int storeOKTransferDone() const
clientStreamNode * getNextNode() const
StoreIOBuffer holdingBuffer
virtual LogTags * loggingTags() const
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:41
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196
#define DBG_CRITICAL
Definition: Stream.h:40
#define EBIT_TEST(flag, bit)
Definition: defines.h:69
@ IN_MEMORY
Definition: enums.h:36
@ HTCP_CLR_INVALIDATION
Definition: enums.h:243
@ HTCP_CLR_PURGE
Definition: enums.h:242
@ 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:272
int shutting_down
const char * null_string
err_type aclGetDenyInfoPage(AclDenyInfoList **head, const char *name, int redirect_allowed)
Definition: Gadgets.cc:42
const char * AclMatchedName
Definition: Acl.cc:29
@ ACCESS_ALLOWED
Definition: Acl.h:110
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:719
void ipcacheInvalidateNegative(const char *name)
Definition: ipcache.cc:872
void ipcacheInvalidate(const char *name)
Definition: ipcache.cc:855
void HTTPMSGUNLOCK(M *&a)
Definition: Message.h:149
void HTTPMSGLOCK(Http::Message *a)
Definition: Message.h:160
#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:22
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:926
#define xstrdup
void neighborsHtcpClear(StoreEntry *e, HttpRequest *req, const HttpRequestMethod &method, htcp_clr_reason reason)
Definition: neighbors.cc:1815
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:483
StoreEntry * storeGetPublicByRequest(HttpRequest *req, const KeyScope keyScope)
Definition: store.cc:489
StoreEntry * storeCreateEntry(const char *url, const char *logUrl, const RequestFlags &flags, const HttpRequestMethod &method)
Definition: store.cc:732
StoreEntry * storeGetPublic(const char *uri, const HttpRequestMethod &method)
Definition: store.cc:477
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
void storeClientCopy(store_client *sc, StoreEntry *e, StoreIOBuffer copyInto, STCB *callback, 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.
char method[16]
Definition: tcp-banger2.c:115
unsigned complete
we have read all we can from upstream
Definition: parse.c:104
struct node * next
Definition: parse.c:105
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
const char * uniqueHostname(void)
Definition: tools.cc:544
#define PRId64
Definition: types.h:110
#define safe_free(x)
Definition: xalloc.h:73

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors