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