client_side_request.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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:
45 
46  String rangeBoundaryStr() const;
47  void freeResources();
48  void updateCounters();
49  void logRequest();
50  MemObject * memObject() const {
51  return (storeEntry() ? storeEntry()->mem_obj : nullptr);
52  }
53  bool multipartRangeRequest() const;
54  void processRequest();
55  void httpStart();
56  bool onlyIfCached()const;
57  bool gotEnough() const;
58  StoreEntry *storeEntry() const { return entry_; }
59  void storeEntry(StoreEntry *);
60  StoreEntry *loggingEntry() const { return loggingEntry_; }
61  void loggingEntry(StoreEntry *);
62 
64  return (cbdataReferenceValid(conn_) ? conn_ : nullptr);
65  }
66 
70  void initRequest(HttpRequest *);
71 
75  void resetRequest(HttpRequest *);
76 
78  void updateLoggingTags(const LogTags_ot code) { al->cache.code.update(code); }
79 
81  const LogTags &loggingTags() const { return al->cache.code; }
82 
83  int64_t mRangeCLen() const;
84 
85  void doCallouts();
86 
87  // The three methods below prepare log_uri and friends for future logging.
88  // Call the best-fit method whenever the current request or its URI changes.
89 
91  void setLogUriToRequestUri();
92 
95  void setLogUriToRawUri(const char *, const HttpRequestMethod &);
96 
99  void setErrorUri(const char *);
100 
105 
107  void calloutsError(const err_type, const ErrorDetail::Pointer &);
108 
110  void updateError(const Error &);
111 
112 public:
117  HttpRequest * const request = nullptr;
118 
122  char *uri = nullptr;
123 
124  // TODO: remove this field and store the URI directly in al->url
128  char * const log_uri = nullptr;
129 
130  String store_id; /* StoreID for transactions where the request member is nil */
131 
132  struct Out {
138  int64_t offset = 0;
140  uint64_t size = 0;
143  size_t headers_sz = 0;
144  } out;
145 
146  HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
147  size_t req_sz = 0;
148 
150 
151  struct Flags {
152  bool accel = false;
153  bool internal = false;
154  bool done_copying = false;
155  } flags;
156 
157  struct Redirect {
159  char *location = nullptr;
161 
164 
166 
167 private:
169  void absorbLogUri(char *);
171  void clearRequest();
174  void assignRequest(HttpRequest *);
175 
176  int64_t maxReplyBodySize_ = 0;
177  StoreEntry *entry_ = nullptr;
179  ConnStateData * conn_ = nullptr;
180 
181 #if USE_OPENSSL
182 public:
189  void sslBumpStart();
191 
192 private:
195 #endif
196 
197 #if USE_ADAPTATION
198 public:
201 
202  /* AsyncJob API */
203  virtual bool doneAll() const {
204  return Initiator::doneAll() &&
206  false; // TODO: Refactor into a proper AsyncJob
207  }
208  virtual void callException(const std::exception &);
209 
210 private:
213  void handleAdaptationFailure(const ErrorDetail::Pointer &, bool bypassable = false);
214 
217 
218  /* Adaptation::Initiator API */
220  virtual void noteAdaptationAnswer(const Adaptation::Answer &);
221 
222  /* BodyConsumer API */
226 
227  void endRequestSatisfaction();
229  void resumeBodyStorage();
230 
231 private:
234 
237 
240 #endif
241 };
242 
243 /* client http based routines */
245 
249 
250 /* ones that should be elsewhere */
252 
253 #endif /* SQUID_CLIENTSIDEREQUEST_H */
@ bumpPeek
Definition: support.h:126
void setLogUriToRawUri(const char *, const HttpRequestMethod &)
void resetRequest(HttpRequest *)
ClientHttpRequest(ConnStateData *)
common parts of HttpRequest and HttpReply
Definition: Message.h:26
ACLFilledChecklist * clientAclChecklistCreate(const acl_access *, ClientHttpRequest *)
@ scNone
Definition: StatusCode.h:21
struct ClientHttpRequest::Redirect redirect
void initRequest(HttpRequest *)
ConnStateData * getConn() const
virtual void callException(const std::exception &)
called when the job throws during an async call
void tunnelStart(ClientHttpRequest *)
Definition: tunnel.cc:1118
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 startAdaptation(const Adaptation::ServiceGroupPointer &)
Initiate an asynchronous adaptation transaction which will call us back.
void setErrorUri(const char *)
void handleAdaptationFailure(const ErrorDetail::Pointer &, bool bypassable=false)
void updateLoggingTags(const LogTags_ot code)
update the code in the transaction processing tags
struct ClientHttpRequest::Flags flags
@ bumpEnd
Definition: support.h:126
struct ClientHttpRequest::Out out
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:398
StatusCode
Definition: StatusCode.h:20
err_type
Definition: forward.h:14
void assignRequest(HttpRequest *)
HttpHdrRangeIter range_iter
a transaction problem
Definition: Error.h:18
bool multipartRangeRequest() const
Definition: client_side.cc:708
virtual void noteBodyProductionEnded(BodyPipe::Pointer)
@ bumpServerFirst
Definition: support.h:126
void clearRequest()
resets the current request and log_uri to nil
virtual bool doneAll() const
whether positive goal has been reached
virtual bool doneAll() const
whether positive goal has been reached
Definition: AsyncJob.cc:97
ClientHttpRequest(ClientHttpRequest &&)=delete
bool requestSatisfactionMode() const
void CSD(clientStreamNode *, ClientHttpRequest *)
client stream detach
void clientAccessCheck(ClientHttpRequest *)
virtual void noteAdaptationAnswer(const Adaptation::Answer &)
unsigned char code
Definition: html_quote.c:20
uint64_t size
Response header and body bytes written to the client connection.
@ 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 *)
void sslBumpEstablish(Comm::Flag)
virtual void noteBodyProducerAborted(BodyPipe::Pointer)
Ssl::BumpMode sslBumpNeed_
whether (and how) the request needs to be bumped
void handleAdaptedHeader(Http::Message *)
void resumeBodyStorage()
called by StoreEntry when it has more buffer space available
#define acl_access
Definition: forward.h:45
virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer)
@ bumpBump
Definition: support.h:126
void handleAdaptationBlock(const Adaptation::Answer &)
size_t req_sz
raw request size on input, not current request size
LogTags_ot
Definition: LogTags.h:37
String rangeBoundaryStr() const
Definition: client_side.cc:792
const AccessLogEntry::Pointer al
access.log entry
CbcPointer< Adaptation::Initiate > virginHeadSource
void setLogUriToRequestUri()
sets log_uri when we know the current request
void calloutsError(const err_type, const ErrorDetail::Pointer &)
Build an error reply. For use with the callouts.
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
void CSCB(clientStreamNode *, ClientHttpRequest *, HttpReply *, StoreIOBuffer)
client stream read callback
void updateError(const Error &)
if necessary, stores new error information (if any)
void absorbLogUri(char *)
assigns log_uri with aUri without copying the entire C-string
virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer)
int clientBeginRequest(const HttpRequestMethod &, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t, const MasterXactionPointer &)
HttpRequest *const request
int64_t mRangeCLen() const
Definition: client_side.cc:752
BodyPipe::Pointer adaptedBodySource

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors