]> git.ipfire.org Git - thirdparty/squid.git/blob - src/client_side_request.h
sourceformat: split protos.h into more specific headers, change many functions' likag...
[thirdparty/squid.git] / src / client_side_request.h
1 /*
2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
4 *
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 *
28 */
29
30 #ifndef SQUID_CLIENTSIDEREQUEST_H
31 #define SQUID_CLIENTSIDEREQUEST_H
32
33 #include "HttpHeader.h"
34 #include "clientStream.h"
35 #include "client_side.h"
36 #include "AccessLogEntry.h"
37 #include "dlink.h"
38 #include "base/AsyncJob.h"
39 #include "HttpHeaderRange.h"
40
41 #if USE_ADAPTATION
42 #include "adaptation/forward.h"
43 #include "adaptation/Initiator.h"
44 class HttpMsg;
45 #endif
46
47 class acl_access;
48 class ACLFilledChecklist;
49 class ClientRequestContext;
50 class ConnStateData;
51 class MemObject;
52
53 /* client_side_request.c - client side request related routines (pure logic) */
54 int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t);
55
56 class ClientHttpRequest
57 #if USE_ADAPTATION
58 : public Adaptation::Initiator, // to start adaptation transactions
59 public BodyConsumer // to receive reply bodies in request satisf. mode
60 #endif
61 {
62
63 public:
64 void *operator new (size_t);
65 void operator delete (void *);
66 #if USE_ADAPTATION
67 void *toCbdata() { return this; }
68 #endif
69 ClientHttpRequest(ConnStateData *csd);
70 ~ClientHttpRequest();
71 /* Not implemented - present to prevent synthetic operations */
72 ClientHttpRequest(ClientHttpRequest const &);
73 ClientHttpRequest& operator=(ClientHttpRequest const &);
74
75 String rangeBoundaryStr() const;
76 void freeResources();
77 void updateCounters();
78 void logRequest();
79 _SQUID_INLINE_ MemObject * memObject() const;
80 bool multipartRangeRequest() const;
81 void processRequest();
82 void httpStart();
83 bool onlyIfCached()const;
84 bool gotEnough() const;
85 _SQUID_INLINE_ StoreEntry *storeEntry() const;
86 void storeEntry(StoreEntry *);
87 _SQUID_INLINE_ StoreEntry *loggingEntry() const;
88 void loggingEntry(StoreEntry *);
89
90 _SQUID_INLINE_ ConnStateData * getConn() const;
91 _SQUID_INLINE_ void setConn(ConnStateData *);
92
93 /** Details of the client socket which produced us.
94 * Treat as read-only for the lifetime of this HTTP request.
95 */
96 Comm::ConnectionPointer clientConnection;
97
98 HttpRequest *request; /* Parsed URL ... */
99 char *uri;
100 char *log_uri;
101
102 struct {
103 int64_t offset;
104 int64_t size;
105 size_t headers_sz;
106 } out;
107
108 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
109 size_t req_sz; /* raw request size on input, not current request size */
110 log_type logType;
111
112 struct timeval start_time;
113 AccessLogEntry::Pointer al; ///< access.log entry
114
115 struct {
116 unsigned int accel:1;
117 unsigned int intercepted:1;
118 unsigned int spoof_client_ip:1;
119 unsigned int internal:1;
120 unsigned int done_copying:1;
121 unsigned int purging:1;
122 } flags;
123
124 struct {
125 http_status status;
126 char *location;
127 } redirect;
128
129 dlink_node active;
130 dlink_list client_stream;
131 int mRangeCLen();
132
133 ClientRequestContext *calloutContext;
134 void doCallouts();
135
136 #if USE_ADAPTATION
137 // AsyncJob virtual methods
138 virtual bool doneAll() const {
139 return Initiator::doneAll() &&
140 BodyConsumer::doneAll() && false;
141 }
142 #endif
143
144 private:
145 int64_t maxReplyBodySize_;
146 StoreEntry *entry_;
147 StoreEntry *loggingEntry_;
148 ConnStateData * conn_;
149
150 #if USE_SSL
151 /// whether (and how) the request needs to be bumped
152 Ssl::BumpMode sslBumpNeed_;
153
154 public:
155 /// returns raw sslBump mode value
156 Ssl::BumpMode sslBumpNeed() const { return sslBumpNeed_; }
157 /// returns true if and only if the request needs to be bumped
158 bool sslBumpNeeded() const { return sslBumpNeed_ == Ssl::bumpServerFirst || sslBumpNeed_ == Ssl::bumpClientFirst; }
159 /// set the sslBumpNeeded state
160 void sslBumpNeed(Ssl::BumpMode mode);
161 void sslBumpStart();
162 void sslBumpEstablish(comm_err_t errflag);
163 #endif
164
165 #if USE_ADAPTATION
166
167 public:
168 void startAdaptation(const Adaptation::ServiceGroupPointer &g);
169
170 // private but exposed for ClientRequestContext
171 void handleAdaptationFailure(int errDetail, bool bypassable = false);
172
173 private:
174 // Adaptation::Initiator API
175 virtual void noteAdaptationAnswer(const Adaptation::Answer &answer);
176 void handleAdaptedHeader(HttpMsg *msg);
177 void handleAdaptationBlock(const Adaptation::Answer &answer);
178 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group);
179
180 // BodyConsumer API, called by BodyPipe
181 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer);
182 virtual void noteBodyProductionEnded(BodyPipe::Pointer);
183 virtual void noteBodyProducerAborted(BodyPipe::Pointer);
184
185 void endRequestSatisfaction();
186 /// called by StoreEntry when it has more buffer space available
187 void resumeBodyStorage();
188
189 private:
190 CbcPointer<Adaptation::Initiate> virginHeadSource;
191 BodyPipe::Pointer adaptedBodySource;
192
193 bool request_satisfaction_mode;
194 int64_t request_satisfaction_offset;
195 #endif
196
197 private:
198 CBDATA_CLASS(ClientHttpRequest);
199 };
200
201 /* client http based routines */
202 char *clientConstructTraceEcho(ClientHttpRequest *);
203
204 ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
205 int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
206 void clientAccessCheck(ClientHttpRequest *);
207
208 /* ones that should be elsewhere */
209 void redirectStart(ClientHttpRequest *, RH *, void *);
210 void tunnelStart(ClientHttpRequest *, int64_t *, int *);
211
212 #if _USE_INLINE_
213 #include "Store.h"
214 #include "client_side_request.cci"
215 #endif
216
217 #endif /* SQUID_CLIENTSIDEREQUEST_H */