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"
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{
40
41public:
45
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 *);
62
64 return (cbdataReferenceValid(conn_) ? conn_ : nullptr);
65 }
66
71
76
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
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
112public:
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;
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;
156
157 struct Redirect {
159 char *location = nullptr;
161
164
166
167private:
169 void absorbLogUri(char *);
171 void clearRequest();
175
176 int64_t maxReplyBodySize_ = 0;
177 StoreEntry *entry_ = nullptr;
179 ConnStateData * conn_ = nullptr;
180
181#if USE_OPENSSL
182public:
189 void sslBumpStart();
191
192private:
195#endif
196
197#if USE_ADAPTATION
198public:
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
210private:
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
229 void resumeBodyStorage();
230
231private:
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 */
LogTags_ot
Definition: LogTags.h:37
#define acl_access
Definition: forward.h:45
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:398
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
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 *)
virtual void callException(const std::exception &)
called when the job throws during an async call
struct ClientHttpRequest::Out out
void clearRequest()
resets the current request and log_uri to nil
HttpRequest *const request
virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer)
void resumeBodyStorage()
called by StoreEntry when it has more buffer space available
virtual void noteBodyProductionEnded(BodyPipe::Pointer)
bool receivedWholeAdaptedReply
noteBodyProductionEnded() was called
StoreEntry * loggingEntry_
int64_t mRangeCLen() const
Definition: client_side.cc:753
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
virtual bool doneAll() const
whether positive goal has been reached
String rangeBoundaryStr() const
Definition: client_side.cc:793
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)
virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer)
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
ConnStateData * conn_
virtual void noteAdaptationAnswer(const Adaptation::Answer &)
void setErrorUri(const char *)
BodyPipe::Pointer adaptedBodySource
Ssl::BumpMode sslBumpNeed_
whether (and how) the request needs to be bumped
HttpHdrRangeIter range_iter
void handleAdaptedHeader(Http::Message *)
struct ClientHttpRequest::Flags flags
bool multipartRangeRequest() const
Definition: client_side.cc:709
void resetRequest(HttpRequest *)
bool requestSatisfactionMode() const
ClientHttpRequest(ClientHttpRequest &&)=delete
void assignRequest(HttpRequest *)
StoreEntry * storeEntry() const
void handleAdaptationBlock(const Adaptation::Answer &)
virtual void noteBodyProducerAborted(BodyPipe::Pointer)
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:1118
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