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
85 // XXX: unify the uriChanged condition calculation with resetRequest() callers, removing this method
88 void resetRequestXXX(HttpRequest *, bool uriChanged);
89
92
95
97 const LogTags &loggingTags() const { return al->cache.code; }
98
99 int64_t mRangeCLen() const;
100
101 void doCallouts();
102
103 // The three methods below prepare log_uri and friends for future logging.
104 // Call the best-fit method whenever the current request or its URI changes.
105
108
111 void setLogUriToRawUri(const char *, const HttpRequestMethod &);
112
115 void setErrorUri(const char *);
116
121
123 void calloutsError(const err_type, const ErrorDetail::Pointer &);
124
126 void updateError(const Error &);
127
128public:
133 HttpRequest * const request = nullptr;
134
138 char *uri = nullptr;
139
140 // TODO: remove this field and store the URI directly in al->url
144 char * const log_uri = nullptr;
145
146 String store_id; /* StoreID for transactions where the request member is nil */
147
148 struct Out {
154 int64_t offset = 0;
156 uint64_t size = 0;
158 size_t headers_sz = 0;
160
161 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
162 size_t req_sz = 0;
163
165
166 struct Flags {
167 bool accel = false;
168 bool done_copying = false;
170
171 struct Redirect {
173 char *location = nullptr;
175
178
180
181private:
183 void absorbLogUri(char *);
185 void clearRequest();
189
190 int64_t maxReplyBodySize_ = 0;
191 StoreEntry *entry_ = nullptr;
193 ConnStateData * conn_ = nullptr;
194
195#if USE_OPENSSL
196public:
203 void sslBumpStart();
205
206private:
209#endif
210
211#if USE_ADAPTATION
212public:
215
216 /* AsyncJob API */
217 bool doneAll() const override {
218 return Initiator::doneAll() &&
220 false; // TODO: Refactor into a proper AsyncJob
221 }
222 void callException(const std::exception &) override;
223
224private:
227 void handleAdaptationFailure(const ErrorDetail::Pointer &, bool bypassable = false);
228
231
232 /* Adaptation::Initiator API */
234 void noteAdaptationAnswer(const Adaptation::Answer &) override;
235
236 /* BodyConsumer API */
240
243 void resumeBodyStorage();
244
245private:
248
251
254#endif
255};
256
257/* client http based routines */
259
263
264/* ones that should be elsewhere */
266
267#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:112
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 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
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
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: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
Flag
Definition: Flag.h:15
StatusCode
Definition: StatusCode.h:20
@ scNone
Definition: StatusCode.h:21
int code
Definition: smb-errors.c:145
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.

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors