client_side_request.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_CLIENTSIDEREQUEST_H
10#define SQUID_CLIENTSIDEREQUEST_H
11
12#include "AccessLogEntry.h"
13#include "client_side.h"
14#include "clientStream.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
30/* client_side_request.c - client side request related routines (pure logic) */
31int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t, const MasterXactionPointer &);
32
34#if USE_ADAPTATION
35 : public Adaptation::Initiator, // to start adaptation transactions
36 public BodyConsumer // to receive reply bodies in request satisf. mode
37#endif
38{
39#if USE_ADAPTATION
41#else
43#endif
44
45public:
48#if USE_ADAPTATION
49 ~ClientHttpRequest() override;
50#else
52#endif
53
55 void freeResources();
56 void updateCounters();
57 void logRequest();
58 MemObject * memObject() const {
59 return (storeEntry() ? storeEntry()->mem_obj : nullptr);
60 }
61 bool multipartRangeRequest() const;
62 void processRequest();
63 void httpStart();
64 bool onlyIfCached()const;
65 bool gotEnough() const;
66 StoreEntry *storeEntry() const { return entry_; }
67 void storeEntry(StoreEntry *);
70
72 return (cbdataReferenceValid(conn_) ? conn_ : nullptr);
73 }
74
79
84
87
89 const LogTags &loggingTags() const { return al->cache.code; }
90
91 int64_t mRangeCLen() const;
92
93 void doCallouts();
94
95 // The three methods below prepare log_uri and friends for future logging.
96 // Call the best-fit method whenever the current request or its URI changes.
97
100
103 void setLogUriToRawUri(const char *, const HttpRequestMethod &);
104
107 void setErrorUri(const char *);
108
113
115 void calloutsError(const err_type, const ErrorDetail::Pointer &);
116
118 void updateError(const Error &);
119
120public:
125 HttpRequest * const request = nullptr;
126
130 char *uri = nullptr;
131
132 // TODO: remove this field and store the URI directly in al->url
136 char * const log_uri = nullptr;
137
138 String store_id; /* StoreID for transactions where the request member is nil */
139
140 struct Out {
146 int64_t offset = 0;
148 uint64_t size = 0;
151 size_t headers_sz = 0;
153
154 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
155 size_t req_sz = 0;
156
158
159 struct Flags {
160 bool accel = false;
161 bool internal = false;
162 bool done_copying = false;
164
165 struct Redirect {
167 char *location = nullptr;
169
172
174
175private:
177 void absorbLogUri(char *);
179 void clearRequest();
183
184 int64_t maxReplyBodySize_ = 0;
185 StoreEntry *entry_ = nullptr;
187 ConnStateData * conn_ = nullptr;
188
189#if USE_OPENSSL
190public:
197 void sslBumpStart();
199
200private:
203#endif
204
205#if USE_ADAPTATION
206public:
209
210 /* AsyncJob API */
211 bool doneAll() const override {
212 return Initiator::doneAll() &&
214 false; // TODO: Refactor into a proper AsyncJob
215 }
216 void callException(const std::exception &) override;
217
218private:
221 void handleAdaptationFailure(const ErrorDetail::Pointer &, bool bypassable = false);
222
225
226 /* Adaptation::Initiator API */
228 void noteAdaptationAnswer(const Adaptation::Answer &) override;
229
230 /* BodyConsumer API */
234
237 void resumeBodyStorage();
238
239private:
242
245
248#endif
249};
250
251/* client http based routines */
253
257
258/* ones that should be elsewhere */
260
261#endif /* SQUID_CLIENTSIDEREQUEST_H */
LogTags_ot
Definition: LogTags.h:37
#define acl_access
Definition: forward.h:45
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:265
#define CBDATA_CLASS(type)
Definition: cbdata.h:289
class AccessLogEntry::CacheDetails cache
summarizes adaptation service answer for the noteAdaptationAnswer() API
Definition: Answer.h:23
virtual bool doneAll() const
whether positive goal has been reached
Definition: AsyncJob.cc:97
int64_t prepPartialResponseGeneration()
ClientHttpRequest(ConnStateData *)
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
StoreEntry * loggingEntry_
int64_t mRangeCLen() const
Definition: client_side.cc:764
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
Definition: client_side.cc:804
void initRequest(HttpRequest *)
void setLogUriToRequestUri()
sets log_uri when we know the current request
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
ConnStateData * conn_
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
Definition: client_side.cc:720
void resetRequest(HttpRequest *)
bool requestSatisfactionMode() const
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:18
common parts of HttpRequest and HttpReply
Definition: Message.h:26
void update(const LogTags_ot t)
Definition: LogTags.cc:54
void CSD(clientStreamNode *, ClientHttpRequest *)
client stream detach
void CSCB(clientStreamNode *, ClientHttpRequest *, HttpReply *, StoreIOBuffer)
client stream read callback
ACLFilledChecklist * clientAclChecklistCreate(const acl_access *, ClientHttpRequest *)
void clientAccessCheck(ClientHttpRequest *)
void tunnelStart(ClientHttpRequest *)
Definition: tunnel.cc:1139
void clientAclChecklistFill(ACLFilledChecklist &, ClientHttpRequest *)
char * clientConstructTraceEcho(ClientHttpRequest *)
int clientBeginRequest(const HttpRequestMethod &, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t, const MasterXactionPointer &)
err_type
Definition: forward.h:14
BumpMode
Definition: support.h:126
@ bumpEnd
Definition: support.h:126
@ bumpPeek
Definition: support.h:126
@ bumpClientFirst
Definition: support.h:126
@ bumpStare
Definition: support.h:126
@ bumpBump
Definition: support.h:126
@ bumpServerFirst
Definition: support.h:126
unsigned char code
Definition: html_quote.c:20
Flag
Definition: Flag.h:15
StatusCode
Definition: StatusCode.h:20
@ scNone
Definition: StatusCode.h:21
uint64_t size
Response header and body bytes written to the client connection.

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors