]> git.ipfire.org Git - thirdparty/squid.git/blob - src/client_side_request.h
Author: wessels & Christos Tsantilas
[thirdparty/squid.git] / src / client_side_request.h
1
2 /*
3 * $Id: client_side_request.h,v 1.32 2007/08/13 17:20:51 hno Exp $
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
45 #if ICAP_CLIENT
46 #include "ICAP/ICAPServiceRep.h"
47 #include "ICAP/ICAPInitiator.h"
48
49 class HttpMsg;
50 #endif
51
52 /* client_side_request.c - client side request related routines (pure logic) */
53 extern int clientBeginRequest(method_t, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t);
54
55 class MemObject;
56
57 class ConnStateData;
58
59 class ClientRequestContext;
60
61 class ClientHttpRequest
62 #if ICAP_CLIENT
63 : public ICAPInitiator, // to start ICAP transactions
64 public BodyConsumer // to receive reply bodies in request satisf. mode
65 #endif
66 {
67
68 public:
69 void *operator new (size_t);
70 void operator delete (void *);
71
72 ClientHttpRequest(ConnStateData::Pointer);
73 ~ClientHttpRequest();
74 /* Not implemented - present to prevent synthetic operations */
75 ClientHttpRequest(ClientHttpRequest const &);
76 ClientHttpRequest& operator=(ClientHttpRequest const &);
77
78 String rangeBoundaryStr() const;
79 void freeResources();
80 void updateCounters();
81 void logRequest();
82 _SQUID_INLINE_ MemObject * memObject() const;
83 bool multipartRangeRequest() const;
84 void processRequest();
85 void httpStart();
86 bool onlyIfCached()const;
87 bool gotEnough() const;
88 _SQUID_INLINE_ StoreEntry *storeEntry() const;
89 void storeEntry(StoreEntry *);
90 _SQUID_INLINE_ StoreEntry *loggingEntry() const;
91 void loggingEntry(StoreEntry *);
92
93 _SQUID_INLINE_ ConnStateData::Pointer getConn();
94 _SQUID_INLINE_ ConnStateData::Pointer const getConn() const;
95 _SQUID_INLINE_ void setConn(ConnStateData::Pointer);
96 HttpRequest *request; /* Parsed URL ... */
97 char *uri;
98 char *log_uri;
99
100 struct
101 {
102 int64_t offset;
103 int64_t size;
104 size_t headers_sz;
105 }
106
107 out;
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;
113 AccessLogEntry al;
114
115 struct
116 {
117
118 unsigned int accel:
119 1;
120
121 unsigned int transparent:
122 1;
123
124 unsigned int internal:
125 1;
126
127 unsigned int done_copying:
128 1;
129
130 unsigned int purging:
131 1;
132 }
133
134 flags;
135
136 struct
137 {
138 http_status status;
139 char *location;
140 }
141
142 redirect;
143 dlink_node active;
144 dlink_list client_stream;
145 int mRangeCLen();
146
147 int64_t maxReplyBodySize() const;
148 void maxReplyBodySize(int64_t size);
149 bool isReplyBodyTooLarge(int64_t len) const;
150
151 ClientRequestContext *calloutContext;
152 void doCallouts();
153
154 private:
155 CBDATA_CLASS(ClientHttpRequest);
156 int64_t maxReplyBodySize_;
157 StoreEntry *entry_;
158 StoreEntry *loggingEntry_;
159 ConnStateData::Pointer conn_;
160
161 #if ICAP_CLIENT
162
163 public:
164 bool startIcap(ICAPServiceRep::Pointer);
165
166 // private but exposed for ClientRequestContext
167 void handleIcapFailure(bool bypassable = false);
168
169 private:
170 // ICAPInitiator API, called by ICAPXaction
171 virtual void noteIcapAnswer(HttpMsg *message);
172 virtual void noteIcapQueryAbort(bool final);
173
174 // BodyConsumer API, called by BodyPipe
175 virtual void noteMoreBodyDataAvailable(BodyPipe &);
176 virtual void noteBodyProductionEnded(BodyPipe &);
177 virtual void noteBodyProducerAborted(BodyPipe &);
178
179 void endRequestSatisfaction();
180
181 private:
182 ICAPInitiate *icapHeadSource;
183 BodyPipe::Pointer icapBodySource;
184
185 bool request_satisfaction_mode;
186 off_t request_satisfaction_offset;
187 #endif
188 };
189
190 /* client http based routines */
191 SQUIDCEXTERN char *clientConstructTraceEcho(ClientHttpRequest *);
192 SQUIDCEXTERN ACLChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
193 SQUIDCEXTERN int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
194 SQUIDCEXTERN void clientAccessCheck(ClientHttpRequest *);
195
196 /* ones that should be elsewhere */
197 SQUIDCEXTERN void redirectStart(ClientHttpRequest *, RH *, void *);
198
199 SQUIDCEXTERN void tunnelStart(ClientHttpRequest *, int64_t *, int *);
200
201 #ifdef _USE_INLINE_
202 #include "Store.h"
203 #include "client_side_request.cci"
204 #endif
205
206 #endif /* SQUID_CLIENTSIDEREQUEST_H */