client_side_request.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 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"
23 #include "adaptation/Initiator.h"
24 #endif
25 
27 class ConnStateData;
28 class MemObject;
29 
30 /* client_side_request.c - client side request related routines (pure logic) */
31 int 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 {
40 
41 public:
44  /* Not implemented - present to prevent synthetic operations */
47 
48  String rangeBoundaryStr() const;
49  void freeResources();
50  void updateCounters();
51  void logRequest();
52  MemObject * memObject() const {
53  return (storeEntry() ? storeEntry()->mem_obj : nullptr);
54  }
55  bool multipartRangeRequest() const;
56  void processRequest();
57  void httpStart();
58  bool onlyIfCached()const;
59  bool gotEnough() const;
60  StoreEntry *storeEntry() const { return entry_; }
61  void storeEntry(StoreEntry *);
62  StoreEntry *loggingEntry() const { return loggingEntry_; }
63  void loggingEntry(StoreEntry *);
64 
65  ConnStateData * getConn() const {
66  return (cbdataReferenceValid(conn_) ? conn_ : nullptr);
67  }
68 
72  void initRequest(HttpRequest *);
73 
77  void resetRequest(HttpRequest *);
78 
80  void updateLoggingTags(const LogTags_ot code) { al->cache.code.update(code); }
81 
83  const LogTags &loggingTags() const { return al->cache.code; }
84 
89 
95 
99  char *uri;
100 
101  // TODO: remove this field and store the URI directly in al->url
105  char * const log_uri;
106 
107  String store_id; /* StoreID for transactions where the request member is nil */
108 
109  struct Out {
110  Out() : offset(0), size(0), headers_sz(0) {}
111 
117  int64_t offset;
119  uint64_t size;
122  size_t headers_sz;
123  } out;
124 
125  HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
126  size_t req_sz; /* raw request size on input, not current request size */
127 
129 
130  struct Flags {
132 
133  bool accel;
134  bool internal;
136  } flags;
137 
138  struct Redirect {
140 
142  char *location;
144 
147  int64_t mRangeCLen() const;
148 
150  void doCallouts();
151 
152  // The three methods below prepare log_uri and friends for future logging.
153  // Call the best-fit method whenever the current request or its URI changes.
154 
156  void setLogUriToRequestUri();
159  void setLogUriToRawUri(const char *rawUri, const HttpRequestMethod &);
162  void setErrorUri(const char *errorUri);
163 
168 
170  void calloutsError(const err_type error, const ErrorDetail::Pointer &errDetail);
171 
173  void updateError(const Error &error);
174 
175 #if USE_ADAPTATION
176  // AsyncJob virtual methods
177  virtual bool doneAll() const {
178  return Initiator::doneAll() &&
179  BodyConsumer::doneAll() && false;
180  }
181  virtual void callException(const std::exception &ex);
182 #endif
183 
184 private:
186  void absorbLogUri(char *aUri);
188  void clearRequest();
191  void assignRequest(HttpRequest *aRequest);
192 
197 
198 #if USE_OPENSSL
201 
202 public:
208  void sslBumpNeed(Ssl::BumpMode mode);
209  void sslBumpStart();
210  void sslBumpEstablish(Comm::Flag errflag);
211 #endif
212 
213 #if USE_ADAPTATION
214 
215 public:
218 
219 private:
222  void handleAdaptationFailure(const ErrorDetail::Pointer &errDetail, bool bypassable = false);
223 
224  // Adaptation::Initiator API
225  virtual void noteAdaptationAnswer(const Adaptation::Answer &answer);
227  void handleAdaptationBlock(const Adaptation::Answer &answer);
229 
230  // BodyConsumer API, called by BodyPipe
234 
235  void endRequestSatisfaction();
237  void resumeBodyStorage();
238 
239 private:
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 */
262 
@ bumpPeek
Definition: support.h:126
void absorbLogUri(char *aUri)
assigns log_uri with aUri without copying the entire C-string
void resetRequest(HttpRequest *)
ClientHttpRequest & operator=(ClientHttpRequest const &)
void assignRequest(HttpRequest *aRequest)
common parts of HttpRequest and HttpReply
Definition: Message.h:26
virtual void noteAdaptationAnswer(const Adaptation::Answer &answer)
@ scNone
Definition: StatusCode.h:21
struct ClientHttpRequest::Redirect redirect
void initRequest(HttpRequest *)
ConnStateData * getConn() const
void setErrorUri(const char *errorUri)
void tunnelStart(ClientHttpRequest *)
Definition: tunnel.cc:1103
void error(char *format,...)
bool sslBumpNeeded() const
returns true if and only if the request needs to be bumped
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
int64_t prepPartialResponseGeneration()
BumpMode
Definition: support.h:126
void calloutsError(const err_type error, const ErrorDetail::Pointer &errDetail)
Build an error reply. For use with the callouts.
void updateLoggingTags(const LogTags_ot code)
update the code in the transaction processing tags
struct ClientHttpRequest::Flags flags
struct ClientHttpRequest::Out out
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:398
StatusCode
Definition: StatusCode.h:20
err_type
Definition: forward.h:14
Definition: forward.h:22
void handleAdaptedHeader(Http::Message *msg)
virtual void callException(const std::exception &ex)
called when the job throws during an async call
HttpHdrRangeIter range_iter
a transaction problem
Definition: Error.h:18
bool multipartRangeRequest() const
Definition: client_side.cc:713
virtual void noteBodyProductionEnded(BodyPipe::Pointer)
@ bumpServerFirst
Definition: support.h:126
void setLogUriToRawUri(const char *rawUri, const HttpRequestMethod &)
void clearRequest()
resets the current request and log_uri to nil
virtual bool doneAll() const
whether positive goal has been reached
#define NULL
Definition: types.h:166
virtual bool doneAll() const
whether positive goal has been reached
Definition: AsyncJob.cc:97
bool requestSatisfactionMode() const
void CSD(clientStreamNode *, ClientHttpRequest *)
client stream detach
void handleAdaptationBlock(const Adaptation::Answer &answer)
void clientAccessCheck(ClientHttpRequest *)
ClientHttpRequest(ClientHttpRequest const &)
unsigned char code
Definition: html_quote.c:20
Comm::ConnectionPointer clientConnection
ACLFilledChecklist * clientAclChecklistCreate(const acl_access *acl, ClientHttpRequest *http)
uint64_t size
Response header and body bytes written to the client connection.
void updateError(const Error &error)
if necessary, stores new error information (if any)
@ bumpStare
Definition: support.h:126
ConnStateData * conn_
summarizes adaptation service answer for the noteAdaptationAnswer() API
Definition: Answer.h:23
Flag
Definition: Flag.h:15
const LogTags & loggingTags() const
the processing tags associated with this request transaction.
void clientAclChecklistFill(ACLFilledChecklist &, ClientHttpRequest *)
virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group)
virtual void noteBodyProducerAborted(BodyPipe::Pointer)
Ssl::BumpMode sslBumpNeed_
whether (and how) the request needs to be bumped
void resumeBodyStorage()
called by StoreEntry when it has more buffer space available
void handleAdaptationFailure(const ErrorDetail::Pointer &errDetail, bool bypassable=false)
#define acl_access
Definition: forward.h:45
@ bumpBump
Definition: support.h:126
LogTags_ot
Definition: LogTags.h:37
String rangeBoundaryStr() const
Definition: client_side.cc:797
const AccessLogEntry::Pointer al
access.log entry
CbcPointer< Adaptation::Initiate > virginHeadSource
void setLogUriToRequestUri()
sets log_uri when we know the current request
bool receivedWholeAdaptedReply
noteBodyProductionEnded() was called
Ssl::BumpMode sslBumpNeed() const
returns raw sslBump mode value
ClientRequestContext * calloutContext
char * clientConstructTraceEcho(ClientHttpRequest *)
StoreEntry * storeEntry() const
StoreEntry * loggingEntry_
StoreEntry * loggingEntry() const
@ bumpClientFirst
Definition: support.h:126
MemObject * memObject() const
#define false
Definition: GnuRegex.c:233
void startAdaptation(const Adaptation::ServiceGroupPointer &g)
Initiate an asynchronous adaptation transaction which will call us back.
void CSCB(clientStreamNode *, ClientHttpRequest *, HttpReply *, StoreIOBuffer)
client stream read callback
virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer)
int clientBeginRequest(const HttpRequestMethod &, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t, const MasterXactionPointer &)
ClientHttpRequest(ConnStateData *csd)
void sslBumpEstablish(Comm::Flag errflag)
HttpRequest *const request
int64_t mRangeCLen() const
Definition: client_side.cc:757
BodyPipe::Pointer adaptedBodySource

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors