]> git.ipfire.org Git - thirdparty/squid.git/blob - src/client_side_request.h
Merged 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 "acl/forward.h"
34 #include "AccessLogEntry.h"
35 #include "clientStream.h"
36 #include "client_side.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 struct timeval start_time;
109 AccessLogEntry::Pointer al; ///< access.log entry
110
111 struct {
112 bool accel;
113 //bool intercepted; //XXX: it's apparently never used.
114 //bool spoof_client_ip; //XXX: it's apparently never used.
115 bool internal;
116 bool done_copying;
117 bool purging;
118 } flags;
119
120 struct {
121 Http::StatusCode status;
122 char *location;
123 } redirect;
124
125 dlink_node active;
126 dlink_list client_stream;
127 int mRangeCLen();
128
129 ClientRequestContext *calloutContext;
130 void doCallouts();
131
132 #if USE_ADAPTATION
133 // AsyncJob virtual methods
134 virtual bool doneAll() const {
135 return Initiator::doneAll() &&
136 BodyConsumer::doneAll() && false;
137 }
138 #endif
139
140 private:
141 int64_t maxReplyBodySize_;
142 StoreEntry *entry_;
143 StoreEntry *loggingEntry_;
144 ConnStateData * conn_;
145
146 #if USE_SSL
147 /// whether (and how) the request needs to be bumped
148 Ssl::BumpMode sslBumpNeed_;
149
150 public:
151 /// returns raw sslBump mode value
152 Ssl::BumpMode sslBumpNeed() const { return sslBumpNeed_; }
153 /// returns true if and only if the request needs to be bumped
154 bool sslBumpNeeded() const { return sslBumpNeed_ == Ssl::bumpServerFirst || sslBumpNeed_ == Ssl::bumpClientFirst; }
155 /// set the sslBumpNeeded state
156 void sslBumpNeed(Ssl::BumpMode mode);
157 void sslBumpStart();
158 void sslBumpEstablish(comm_err_t errflag);
159 #endif
160
161 #if USE_ADAPTATION
162
163 public:
164 void startAdaptation(const Adaptation::ServiceGroupPointer &g);
165
166 // private but exposed for ClientRequestContext
167 void handleAdaptationFailure(int errDetail, bool bypassable = false);
168
169 private:
170 // Adaptation::Initiator API
171 virtual void noteAdaptationAnswer(const Adaptation::Answer &answer);
172 void handleAdaptedHeader(HttpMsg *msg);
173 void handleAdaptationBlock(const Adaptation::Answer &answer);
174 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group);
175
176 // BodyConsumer API, called by BodyPipe
177 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer);
178 virtual void noteBodyProductionEnded(BodyPipe::Pointer);
179 virtual void noteBodyProducerAborted(BodyPipe::Pointer);
180
181 void endRequestSatisfaction();
182 /// called by StoreEntry when it has more buffer space available
183 void resumeBodyStorage();
184
185 private:
186 CbcPointer<Adaptation::Initiate> virginHeadSource;
187 BodyPipe::Pointer adaptedBodySource;
188
189 bool request_satisfaction_mode;
190 int64_t request_satisfaction_offset;
191 #endif
192
193 private:
194 CBDATA_CLASS2(ClientHttpRequest);
195 };
196
197 /* client http based routines */
198 char *clientConstructTraceEcho(ClientHttpRequest *);
199
200 ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
201 int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
202 void clientAccessCheck(ClientHttpRequest *);
203
204 /* ones that should be elsewhere */
205 void tunnelStart(ClientHttpRequest *, int64_t *, int *, const AccessLogEntry::Pointer &al);
206
207 #if _USE_INLINE_
208 #include "Store.h"
209 #include "client_side_request.cci"
210 #endif
211
212 #endif /* SQUID_CLIENTSIDEREQUEST_H */