Squid Web Cache master
Loading...
Searching...
No Matches
client_side_request.h
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#ifndef SQUID_SRC_CLIENT_SIDE_REQUEST_H
10#define SQUID_SRC_CLIENT_SIDE_REQUEST_H
11
12#include "AccessLogEntry.h"
13#include "acl/FilledChecklist.h"
14#include "client_side.h"
15#include "http/forward.h"
16#include "HttpHeaderRange.h"
17#include "log/forward.h"
18#include "LogTags.h"
19#include "Store.h"
20
21#if USE_ADAPTATION
22#include "adaptation/forward.h"
24#endif
25
27class ConnStateData;
28class MemObject;
29
32 : public Adaptation::Initiator, // to start adaptation transactions
33 public BodyConsumer // to receive reply bodies in request satisf. mode
34#endif
35{
36#if USE_ADAPTATION
38#else
40#endif
41
42public:
45#if USE_ADAPTATION
46 ~ClientHttpRequest() override;
47#else
49#endif
50
52 void freeResources();
53 void updateCounters();
54 void logRequest();
55 MemObject * memObject() const {
56 return (storeEntry() ? storeEntry()->mem_obj : nullptr);
57 }
58 bool multipartRangeRequest() const;
59 void processRequest();
60 void httpStart();
61 bool onlyIfCached()const;
62 bool gotEnough() const;
63 StoreEntry *storeEntry() const { return entry_; }
64 void storeEntry(StoreEntry *);
67
69 return (cbdataReferenceValid(conn_) ? conn_ : nullptr);
70 }
71
76
81
82 // XXX: unify the uriChanged condition calculation with resetRequest() callers, removing this method
85 void resetRequestXXX(HttpRequest *, bool uriChanged);
86
89
91 void updateLoggingTags(const LogTags_ot code) { al->cache.code.update(code); }
92
94 const LogTags &loggingTags() const { return al->cache.code; }
95
96 int64_t mRangeCLen() const;
97
98 void doCallouts();
99
100 // The three methods below prepare log_uri and friends for future logging.
101 // Call the best-fit method whenever the current request or its URI changes.
102
105
108 void setLogUriToRawUri(const char *, const HttpRequestMethod &);
109
112 void setErrorUri(const char *);
113
118
120 void calloutsError(const err_type, const ErrorDetail::Pointer &);
121
123 void updateError(const Error &);
124
125public:
130 HttpRequest * const request = nullptr;
131
135 char *uri = nullptr;
136
137 // TODO: remove this field and store the URI directly in al->url
141 char * const log_uri = nullptr;
142
143 String store_id; /* StoreID for transactions where the request member is nil */
144
145 struct Out {
151 int64_t offset = 0;
153 uint64_t size = 0;
155 size_t headers_sz = 0;
157
158 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
159 size_t req_sz = 0;
160
162
163 struct Flags {
164 bool accel = false;
165 bool done_copying = false;
167
172
175
177
178private:
180 void absorbLogUri(char *);
182 void clearRequest();
186
187 int64_t maxReplyBodySize_ = 0;
188 StoreEntry *entry_ = nullptr;
190 ConnStateData * conn_ = nullptr;
191
192#if USE_OPENSSL
193public:
200 void sslBumpStart();
202
203private:
206#endif
207
208#if USE_ADAPTATION
209public:
212
213 /* AsyncJob API */
214 bool doneAll() const override {
215 return Initiator::doneAll() &&
217 false; // TODO: Refactor into a proper AsyncJob
218 }
219 void callException(const std::exception &) override;
220
221private:
224 void handleAdaptationFailure(const ErrorDetail::Pointer &, bool bypassable = false);
225
228
229 /* Adaptation::Initiator API */
231 void noteAdaptationAnswer(const Adaptation::Answer &) override;
232
233 /* BodyConsumer API */
237
240 void resumeBodyStorage();
241
242private:
245
248
251#endif
252};
253
254/* client http based routines */
256
260
261/* ones that should be elsewhere */
263
264#endif /* SQUID_SRC_CLIENT_SIDE_REQUEST_H */
LogTags_ot
Definition LogTags.h:40
#define USE_ADAPTATION
Definition autoconf.h:1496
int cbdataReferenceValid(const void *p)
Definition cbdata.cc:270
#define CBDATA_CLASS(type)
Definition cbdata.h:289
std::unique_ptr< ACLFilledChecklist > MakingPointer
class AccessLogEntry::CacheDetails cache
summarizes adaptation service answer for the noteAdaptationAnswer() API
Definition Answer.h:25
virtual bool doneAll() const
whether positive goal has been reached
Definition AsyncJob.cc:112
int64_t prepPartialResponseGeneration()
CBDATA_CHILD(ClientHttpRequest)
void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer) override
void noteMoreBodyDataAvailable(BodyPipe::Pointer) override
struct ClientHttpRequest::Out out
void clearRequest()
resets the current request and log_uri to nil
HttpRequest *const request
void resumeBodyStorage()
called by StoreEntry when it has more buffer space available
bool receivedWholeAdaptedReply
noteBodyProductionEnded() was called
void noteBodyProductionEnded(BodyPipe::Pointer) override
int64_t mRangeCLen() const
void calloutsError(const err_type, const ErrorDetail::Pointer &)
Build an error reply. For use with the callouts.
void absorbLogUri(char *)
assigns log_uri with aUri without copying the entire C-string
ConnStateData * getConn() const
String rangeBoundaryStr() const
void initRequest(HttpRequest *)
void setLogUriToRequestUri()
sets log_uri when we know the current request
void checkForInternalAccess()
Checks whether the current request is internal and adjusts it accordingly.
void updateError(const Error &)
if necessary, stores new error information (if any)
CbcPointer< Adaptation::Initiate > virginHeadSource
void updateLoggingTags(const LogTags_ot code)
update the code in the transaction processing tags
MemObject * memObject() const
void setLogUriToRawUri(const char *, const HttpRequestMethod &)
size_t req_sz
raw request size on input, not current request size
bool doneAll() const override
whether positive goal has been reached
void setErrorUri(const char *)
BodyPipe::Pointer adaptedBodySource
Ssl::BumpMode sslBumpNeed_
whether (and how) the request needs to be bumped
HttpHdrRangeIter range_iter
void noteAdaptationAnswer(const Adaptation::Answer &) override
void handleAdaptedHeader(Http::Message *)
struct ClientHttpRequest::Flags flags
bool multipartRangeRequest() const
void resetRequest(HttpRequest *)
bool requestSatisfactionMode() const
void resetRequestXXX(HttpRequest *, bool uriChanged)
ClientHttpRequest(ClientHttpRequest &&)=delete
void callException(const std::exception &) override
called when the job throws during an async call
void assignRequest(HttpRequest *)
StoreEntry * storeEntry() const
void handleAdaptationBlock(const Adaptation::Answer &)
void noteBodyProducerAborted(BodyPipe::Pointer) override
void sslBumpEstablish(Comm::Flag)
bool sslBumpNeeded() const
returns true if and only if the request needs to be bumped
ClientRequestContext * calloutContext
Ssl::BumpMode sslBumpNeed() const
returns raw sslBump mode value
const LogTags & loggingTags() const
the processing tags associated with this request transaction.
void handleAdaptationFailure(const ErrorDetail::Pointer &, bool bypassable=false)
const AccessLogEntry::Pointer al
access.log entry
StoreEntry * loggingEntry() const
void startAdaptation(const Adaptation::ServiceGroupPointer &)
Initiate an asynchronous adaptation transaction which will call us back.
struct ClientHttpRequest::Redirect redirect
a transaction problem
Definition Error.h:27
common parts of HttpRequest and HttpReply
Definition Message.h:26
void update(const LogTags_ot t)
Definition LogTags.cc:63
void clientAccessCheck(ClientHttpRequest *)
void tunnelStart(ClientHttpRequest *)
Definition tunnel.cc:1259
void clientAclChecklistFill(ACLFilledChecklist &, ClientHttpRequest *)
ACLFilledChecklist::MakingPointer clientAclChecklistCreate(const acl_access *, ClientHttpRequest *)
char * clientConstructTraceEcho(ClientHttpRequest *)
err_type
Definition forward.h:14
BumpMode
Definition support.h:132
@ bumpEnd
Definition support.h:132
@ bumpPeek
Definition support.h:132
@ bumpClientFirst
Definition support.h:132
@ bumpStare
Definition support.h:132
@ bumpBump
Definition support.h:132
@ bumpServerFirst
Definition support.h:132
Flag
Definition Flag.h:15
StatusCode
Definition StatusCode.h:20
@ scNone
Definition StatusCode.h:21
size_t headers_sz
Response header bytes written to the client connection.
uint64_t size
Response header and body bytes written to the client connection.