client_side_reply.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_SRC_CLIENT_SIDE_REPLY_H
10 #define SQUID_SRC_CLIENT_SIDE_REPLY_H
11 
12 #include "acl/forward.h"
13 #include "client_side_request.h"
14 #include "ip/forward.h"
15 #include "RequestFlags.h"
16 #include "StoreClient.h"
17 
18 class ErrorState;
19 
20 /* XXX make static method */
21 
23 {
25 
26 public:
27  static STCB CacheHit;
30 
32  ~clientReplyContext() override;
33 
34  void saveState();
35  void restoreState();
36  void purgeRequest ();
37  void doGetMoreData();
38  void identifyStoreObject();
39  void identifyFoundObject(StoreEntry *entry, const char *detail);
40  int storeOKTransferDone() const;
41  int storeNotOKTransferDone() const;
43  void setReplyToStoreEntry(StoreEntry *e, const char *reason);
45  void setReplyToError(err_type, Http::StatusCode, char const *, const ConnStateData *, HttpRequest *, const char *,
46 #if USE_AUTH
48 #else
49  void * unused);
50 #endif
51  void setReplyToError(const HttpRequestMethod& method, ErrorState *err);
56  void removeStoreReference(store_client ** scp, StoreEntry ** ep);
58  void startError(ErrorState * err);
59  void processExpired();
61  void processMiss();
62  void traceReply();
63  const char *storeId() const { return (http->store_id.size() > 0 ? http->store_id.termedBuf() : http->uri); }
64 
66 
67  /* StoreClient API */
68  LogTags *loggingTags() const override;
69 
71  store_client *sc; /* The store_client we're using */
72 
78 
79  struct Flags {
81 
82  unsigned storelogiccomplete:1;
83  unsigned complete:1;
85  } flags;
86  clientStreamNode *ourNode; /* This will go away if/when this file gets refactored some more */
87 
88 private:
89  /* StoreClient API */
90  void fillChecklist(ACLFilledChecklist &) const override;
91 
93  void makeThisHead();
94  bool errorInStream(const StoreIOBuffer &result) const;
95  bool matchesStreamBodyBuffer(const StoreIOBuffer &) const;
96  void sendStreamError(StoreIOBuffer const &result);
97  void pushStreamData(const StoreIOBuffer &);
98  clientStreamNode * next() const;
100  void processReplyAccess();
102  void processReplyAccessResult(const Acl::Answer &accessAllowed);
103  void cloneReply();
104  void buildReplyHeader ();
105  bool alwaysAllowResponse(Http::StatusCode sline) const;
106  int checkTransferDone();
108  bool processConditional();
110  void cacheHit(StoreIOBuffer result);
111  void handleIMSReply(StoreIOBuffer result);
112  void sendMoreData(StoreIOBuffer result);
115  void sendClientOldEntry();
116  void purgeAllCached();
119  bool purgeEntry(StoreEntry &, const Http::MethodType, const char *descriptionPrefix = "");
121  void purgeDoPurge();
122  void forgetHit();
123  bool blockedHit() const;
124  const char *storeLookupString(bool found) const { return found ? "match" : "mismatch"; }
125  void detailStoreLookup(const char *detail);
126 
127  void sendBodyTooLargeError();
129  void sendNotModified();
131  void sendClientUpstreamResponse(const StoreIOBuffer &upstreamResponse);
132 
137  static decltype(::storeClientCopy) storeClientCopy [[deprecated]];
138 
142  const char *firstStoreLookup_ = nullptr;
143 
144  /* (stale) cache hit information preserved during IMS revalidation */
147  time_t old_lastmod;
149 
150  bool deleting;
151 
152  typedef enum {
153  crNone = 0,
157 
159 
162 
163  // TODO: Remove after moving the meat of this function into a method.
165 };
166 
167 // TODO: move to SideAgent parent, when we have one
168 void purgeEntriesByUrl(HttpRequest *, const char *);
169 
170 #endif /* SQUID_SRC_CLIENT_SIDE_REPLY_H */
171 
void removeClientStoreReference(store_client **scp, ClientHttpRequest *http)
ClientHttpRequest * http
~clientReplyContext() override
void purgeDoPurge()
releases both cached GET and HEAD entries
void sendNotModifiedOrPreconditionFailedError()
void createStoreEntry(const HttpRequestMethod &m, RequestFlags flags)
#define CBDATA_CLASS(type)
Definition: cbdata.h:289
char tempbuf[HTTP_REQBUF_SZ]
void fillChecklist(ACLFilledChecklist &) const override
configure the given checklist (to reflect the current transaction state)
void sendStreamError(StoreIOBuffer const &result)
void removeStoreReference(store_client **scp, StoreEntry **ep)
StatusCode
Definition: StatusCode.h:20
err_type
Definition: forward.h:14
bool errorInStream(const StoreIOBuffer &result) const
Http::StatusCode purgeStatus
CollapsedRevalidation collapsedRevalidation
void sendPreconditionFailedError()
send 412 (Precondition Failed) to client
void identifyFoundObject(StoreEntry *entry, const char *detail)
void ACLCB(Acl::Answer, void *)
ACL checklist callback.
Definition: Checklist.h:23
a storeGetPublic*() caller
Definition: StoreClient.h:40
@ crSlave
we collapsed on the existing revalidation request
void startError(ErrorState *err)
void CSR(clientStreamNode *, ClientHttpRequest *)
client stream read
void purgeEntriesByUrl(HttpRequest *, const char *)
void cacheHit(StoreIOBuffer result)
void sendMoreData(StoreIOBuffer result)
void setReplyToReply(HttpReply *reply)
creates a store entry for the reply and appends error reply to it
void setReplyToStoreEntry(StoreEntry *e, const char *reason)
replaces current response store entry with the given one
void detailStoreLookup(const char *detail)
remembers the very first Store lookup classification, ignoring the rest
static decltype(::storeClientCopy) storeClientCopy
void handleIMSReply(StoreIOBuffer result)
clientStream_status_t replyStatus()
struct clientReplyContext::Flags flags
clientReplyContext(ClientHttpRequest *)
int storeOKTransferDone() const
@ crInitiator
we initiated collapsed revalidation request
friend CSR clientGetMoreData
bool matchesStreamBodyBuffer(const StoreIOBuffer &) const
clientStreamNode * getNextNode() const
enum Http::_method_t MethodType
LogTags * loggingTags() const override
bool blockedHit() const
whether squid.conf send_hit prevents us from serving this hit
const char * termedBuf() const
Definition: SquidString.h:92
const char * storeId() const
bool processConditional()
process conditional request from client
int storeNotOKTransferDone() const
size_type size() const
Definition: SquidString.h:73
StoreIOBuffer lastStreamBufferedBytes
HTTP response body bytes stored in our Client Stream buffer (if any)
@ crNone
collapsed revalidation is not allowed for this context
clientStream_status_t
Definition: enums.h:120
void setReplyToError(err_type, Http::StatusCode, char const *, const ConnStateData *, HttpRequest *, const char *, Auth::UserRequest::Pointer)
builds error using clientBuildError() and calls setReplyToError() below
bool alwaysAllowResponse(Http::StatusCode sline) const
const char * storeLookupString(bool found) const
bool purgeEntry(StoreEntry &, const Http::MethodType, const char *descriptionPrefix="")
#define HTTP_REQBUF_SZ
Definition: forward.h:14
const char * firstStoreLookup_
store_client * old_sc
clientStreamNode * next() const
static ACLCB ProcessReplyAccessResult
void sendNotModified()
send 304 (Not Modified) to client
void processReplyAccessResult(const Acl::Answer &accessAllowed)
clientStreamNode * ourNode
void(void *, StoreIOBuffer) STCB
Definition: StoreClient.h:32
void triggerInitialStoreRead(STCB=SendMoreData)
void pushStreamData(const StoreIOBuffer &)
static STCB SendMoreData
unsigned complete
we have read all we can from upstream
void noteStreamBufferredBytes(const StoreIOBuffer &)
static STCB HandleIMSReply
void sendClientUpstreamResponse(const StoreIOBuffer &upstreamResponse)

 

Introduction

Documentation

Support

Miscellaneous