client_side_request.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 "acl/forward.h"
14 #include "client_side.h"
15 #include "clientStream.h"
16 #include "http/forward.h"
17 #include "HttpHeaderRange.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  void setConn(ConnStateData *aConn) {
69  if (conn_ != aConn) {
71  conn_ = cbdataReference(aConn);
72  }
73  }
74 
78  void initRequest(HttpRequest *);
79 
83  void resetRequest(HttpRequest *);
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 
112  int64_t offset;
113  uint64_t size;
114  size_t headers_sz;
115  } out;
116 
117  HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
118  size_t req_sz; /* raw request size on input, not current request size */
119 
121  // NP: still an enum so each stage altering it must take care when replacing it.
123 
125 
126  struct Flags {
128 
129  bool accel;
130  bool internal;
132  bool purging;
133  } flags;
134 
135  struct Redirect {
137 
139  char *location;
140  } redirect;
141 
144  int mRangeCLen();
145 
147  void doCallouts();
148 
149  // The three methods below prepare log_uri and friends for future logging.
150  // Call the best-fit method whenever the current request or its URI changes.
151 
153  void setLogUriToRequestUri();
156  void setLogUriToRawUri(const char *rawUri, const HttpRequestMethod &);
159  void setErrorUri(const char *errorUri);
160 
162  void calloutsError(const err_type error, const int errDetail);
163 
164 #if USE_ADAPTATION
165  // AsyncJob virtual methods
166  virtual bool doneAll() const {
167  return Initiator::doneAll() &&
168  BodyConsumer::doneAll() && false;
169  }
170  virtual void callException(const std::exception &ex);
171 #endif
172 
173 private:
175  void absorbLogUri(char *aUri);
177  void clearRequest();
180  void assignRequest(HttpRequest *aRequest);
181 
186 
187 #if USE_OPENSSL
190 
191 public:
197  void sslBumpNeed(Ssl::BumpMode mode);
198  void sslBumpStart();
199  void sslBumpEstablish(Comm::Flag errflag);
200 #endif
201 
202 #if USE_ADAPTATION
203 
204 public:
207 
208 private:
211  void handleAdaptationFailure(int errDetail, bool bypassable = false);
212 
213  // Adaptation::Initiator API
214  virtual void noteAdaptationAnswer(const Adaptation::Answer &answer);
216  void handleAdaptationBlock(const Adaptation::Answer &answer);
218 
219  // BodyConsumer API, called by BodyPipe
223 
224  void endRequestSatisfaction();
226  void resumeBodyStorage();
227 
228 private:
231 
234 #endif
235 };
236 
237 /* client http based routines */
239 
242 int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
244 
245 /* ones that should be elsewhere */
247 
248 #endif /* SQUID_CLIENTSIDEREQUEST_H */
249 
summarizes adaptation service answer for the noteAdaptationAnswer() API
Definition: Answer.h:22
virtual bool doneAll() const
whether positive goal has been reached
Definition: AsyncJob.cc:96
ConnStateData * getConn() const
#define cbdataReferenceDone(var)
Definition: cbdata.h:350
int clientHttpRequestStatus(int fd, ClientHttpRequest const *http)
void clientAccessCheck(ClientHttpRequest *)
Ssl::BumpMode sslBumpNeed() const
returns raw sslBump mode value
struct ClientHttpRequest::Redirect redirect
virtual void noteBodyProducerAborted(BodyPipe::Pointer)
virtual void noteBodyProductionEnded(BodyPipe::Pointer)
Comm::ConnectionPointer clientConnection
void setErrorUri(const char *errorUri)
void assignRequest(HttpRequest *aRequest)
void error(char *format,...)
char * clientConstructTraceEcho(ClientHttpRequest *)
ClientHttpRequest(ConnStateData *csd)
int clientBeginRequest(const HttpRequestMethod &method, char const *url, CSCB *streamcallback, CSD *streamdetach, ClientStreamData streamdata, HttpHeader const *header, char *tailbuf, size_t taillen, const MasterXaction::Pointer &mx)
ClientHttpRequest & operator=(ClientHttpRequest const &)
void calloutsError(const err_type error, const int errDetail)
Build an error reply. For use with the callouts.
void handleAdaptedHeader(Http::Message *msg)
virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group)
virtual bool doneAll() const
whether positive goal has been reached
void startAdaptation(const Adaptation::ServiceGroupPointer &g)
Initiate an asynchronous adaptation transaction which will call us back.
void clientAclChecklistFill(ACLFilledChecklist &checklist, ClientHttpRequest *http)
HttpHdrRangeIter range_iter
MemObject * memObject() const
bool multipartRangeRequest() const
Definition: client_side.cc:685
ACLFilledChecklist * clientAclChecklistCreate(const acl_access *acl, ClientHttpRequest *http)
LogTags logType
the processing tags associated with this request transaction.
StatusCode
Definition: StatusCode.h:20
void setConn(ConnStateData *aConn)
#define cbdataReference(var)
Definition: cbdata.h:341
void setLogUriToRawUri(const char *rawUri, const HttpRequestMethod &)
void CSCB(clientStreamNode *, ClientHttpRequest *, HttpReply *, StoreIOBuffer)
client stream read callback
void absorbLogUri(char *aUri)
assigns log_uri with aUri without copying the entire C-string
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
bool onlyIfCached() const
StoreEntry * storeEntry() const
common parts of HttpRequest and HttpReply
Definition: Message.h:25
void handleAdaptationBlock(const Adaptation::Answer &answer)
BodyPipe::Pointer adaptedBodySource
AccessLogEntry::Pointer al
access.log entry
void resumeBodyStorage()
called by StoreEntry when it has more buffer space available
ClientRequestContext * calloutContext
void tunnelStart(ClientHttpRequest *)
Definition: tunnel.cc:1087
void setLogUriToRequestUri()
sets log_uri when we know the current request
struct ClientHttpRequest::Out out
void handleAdaptationFailure(int errDetail, bool bypassable=false)
Flag
Definition: Flag.h:15
Ssl::BumpMode sslBumpNeed_
whether (and how) the request needs to be bumped
void clearRequest()
resets the current request and log_uri to nil
virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer)
StoreEntry * loggingEntry_
bool sslBumpNeeded() const
returns true if and only if the request needs to be bumped
struct ClientHttpRequest::Flags flags
CbcPointer< Adaptation::Initiate > virginHeadSource
ConnStateData * conn_
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:412
void sslBumpEstablish(Comm::Flag errflag)
virtual void noteAdaptationAnswer(const Adaptation::Answer &answer)
HttpRequest *const request
BumpMode
Definition: support.h:131
void initRequest(HttpRequest *)
bool requestSatisfactionMode() const
String rangeBoundaryStr() const
Definition: client_side.cc:769
#define acl_access
Definition: forward.h:44
void CSD(clientStreamNode *, ClientHttpRequest *)
client stream detach
StoreEntry * loggingEntry() const
#define NULL
Definition: types.h:166
#define false
Definition: GnuRegex.c:233
err_type
Definition: err_type.h:12
void resetRequest(HttpRequest *)
virtual void callException(const std::exception &ex)
called when the job throws during an async call

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors