]> git.ipfire.org Git - thirdparty/squid.git/blob - src/client_side_request.h
Merge from trunk
[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 "AccessLogEntry.h"
34 #include "acl/forward.h"
35 #include "client_side.h"
36 #include "clientStream.h"
37 #include "HttpHeaderRange.h"
38 #include "LogTags.h"
39
40 #if USE_ADAPTATION
41 #include "adaptation/forward.h"
42 #include "adaptation/Initiator.h"
43 class HttpMsg;
44 #endif
45
46 class ClientRequestContext;
47 class ConnStateData;
48 class MemObject;
49
50 /* client_side_request.c - client side request related routines (pure logic) */
51 int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t);
52
53 class ClientHttpRequest
54 #if USE_ADAPTATION
55 : public Adaptation::Initiator, // to start adaptation transactions
56 public BodyConsumer // to receive reply bodies in request satisf. mode
57 #endif
58 {
59
60 public:
61 ClientHttpRequest(ConnStateData *csd);
62 ~ClientHttpRequest();
63 /* Not implemented - present to prevent synthetic operations */
64 ClientHttpRequest(ClientHttpRequest const &);
65 ClientHttpRequest& operator=(ClientHttpRequest const &);
66
67 String rangeBoundaryStr() const;
68 void freeResources();
69 void updateCounters();
70 void logRequest();
71 _SQUID_INLINE_ MemObject * memObject() const;
72 bool multipartRangeRequest() const;
73 void processRequest();
74 void httpStart();
75 bool onlyIfCached()const;
76 bool gotEnough() const;
77 _SQUID_INLINE_ StoreEntry *storeEntry() const;
78 void storeEntry(StoreEntry *);
79 _SQUID_INLINE_ StoreEntry *loggingEntry() const;
80 void loggingEntry(StoreEntry *);
81
82 _SQUID_INLINE_ ConnStateData * getConn() const;
83 _SQUID_INLINE_ void setConn(ConnStateData *);
84
85 /** Details of the client socket which produced us.
86 * Treat as read-only for the lifetime of this HTTP request.
87 */
88 Comm::ConnectionPointer clientConnection;
89
90 HttpRequest *request; /* Parsed URL ... */
91 char *uri;
92 char *log_uri;
93 String store_id; /* StoreID for transactions where the request member is nil */
94
95 struct {
96 int64_t offset;
97 int64_t size;
98 size_t headers_sz;
99 } out;
100
101 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
102 size_t req_sz; /* raw request size on input, not current request size */
103
104 /// the processing tags associated with this request transaction.
105 // NP: still an enum so each stage altering it must take care when replacing it.
106 LogTags logType;
107
108 AccessLogEntry::Pointer al; ///< access.log entry
109
110 struct {
111 bool accel;
112 //bool intercepted; //XXX: it's apparently never used.
113 //bool spoof_client_ip; //XXX: it's apparently never used.
114 bool internal;
115 bool done_copying;
116 bool purging;
117 } flags;
118
119 struct {
120 Http::StatusCode status;
121 char *location;
122 } redirect;
123
124 dlink_node active;
125 dlink_list client_stream;
126 int mRangeCLen();
127
128 ClientRequestContext *calloutContext;
129 void doCallouts();
130
131 #if USE_ADAPTATION
132 // AsyncJob virtual methods
133 virtual bool doneAll() const {
134 return Initiator::doneAll() &&
135 BodyConsumer::doneAll() && false;
136 }
137 #endif
138
139 private:
140 int64_t maxReplyBodySize_;
141 StoreEntry *entry_;
142 StoreEntry *loggingEntry_;
143 ConnStateData * conn_;
144
145 #if USE_OPENSSL
146 /// whether (and how) the request needs to be bumped
147 Ssl::BumpMode sslBumpNeed_;
148
149 public:
150 /// returns raw sslBump mode value
151 Ssl::BumpMode sslBumpNeed() const { return sslBumpNeed_; }
152 /// returns true if and only if the request needs to be bumped
153 bool sslBumpNeeded() const { return sslBumpNeed_ == Ssl::bumpServerFirst || sslBumpNeed_ == Ssl::bumpClientFirst || sslBumpNeed_ == Ssl::bumpBump || sslBumpNeed_ == Ssl::bumpPeek || sslBumpNeed_ == Ssl::bumpStare; }
154 /// set the sslBumpNeeded state
155 void sslBumpNeed(Ssl::BumpMode mode);
156 void sslBumpStart();
157 void sslBumpEstablish(Comm::Flag errflag);
158 #endif
159
160 #if USE_ADAPTATION
161
162 public:
163 void startAdaptation(const Adaptation::ServiceGroupPointer &g);
164
165 // private but exposed for ClientRequestContext
166 void handleAdaptationFailure(int errDetail, bool bypassable = false);
167
168 private:
169 // Adaptation::Initiator API
170 virtual void noteAdaptationAnswer(const Adaptation::Answer &answer);
171 void handleAdaptedHeader(HttpMsg *msg);
172 void handleAdaptationBlock(const Adaptation::Answer &answer);
173 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group);
174
175 // BodyConsumer API, called by BodyPipe
176 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer);
177 virtual void noteBodyProductionEnded(BodyPipe::Pointer);
178 virtual void noteBodyProducerAborted(BodyPipe::Pointer);
179
180 void endRequestSatisfaction();
181 /// called by StoreEntry when it has more buffer space available
182 void resumeBodyStorage();
183
184 private:
185 CbcPointer<Adaptation::Initiate> virginHeadSource;
186 BodyPipe::Pointer adaptedBodySource;
187
188 bool request_satisfaction_mode;
189 int64_t request_satisfaction_offset;
190 #endif
191
192 private:
193 CBDATA_CLASS2(ClientHttpRequest);
194 };
195
196 /* client http based routines */
197 char *clientConstructTraceEcho(ClientHttpRequest *);
198
199 ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
200 int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
201 void clientAccessCheck(ClientHttpRequest *);
202
203 /* ones that should be elsewhere */
204 void tunnelStart(ClientHttpRequest *, int64_t *, int *, const AccessLogEntry::Pointer &al);
205
206 #if _USE_INLINE_
207 #include "client_side_request.cci"
208 #include "Store.h"
209 #endif
210
211 #endif /* SQUID_CLIENTSIDEREQUEST_H */