]>
Commit | Line | Data |
---|---|---|
c8be6d7b | 1 | |
2 | /* | |
47f6e231 | 3 | * $Id: client_side_request.h,v 1.32 2007/08/13 17:20:51 hno Exp $ |
c8be6d7b | 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 | ||
b1b15292 | 34 | |
c8be6d7b | 35 | #ifndef SQUID_CLIENTSIDEREQUEST_H |
36 | #define SQUID_CLIENTSIDEREQUEST_H | |
37 | ||
b1b15292 | 38 | #include "squid.h" |
528b2c61 | 39 | #include "HttpHeader.h" |
40 | #include "clientStream.h" | |
a2ac85d9 | 41 | #include "client_side.h" |
450e0c10 | 42 | #include "AccessLogEntry.h" |
b1b15292 | 43 | #include "dlink.h" |
528b2c61 | 44 | |
de31d06f | 45 | #if ICAP_CLIENT |
46 | #include "ICAP/ICAPServiceRep.h" | |
5f8252d2 | 47 | #include "ICAP/ICAPInitiator.h" |
de31d06f | 48 | |
49 | class HttpMsg; | |
50 | #endif | |
51 | ||
c8be6d7b | 52 | /* client_side_request.c - client side request related routines (pure logic) */ |
0655fa4d | 53 | extern int clientBeginRequest(method_t, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t); |
c8be6d7b | 54 | |
90f396d5 | 55 | class MemObject; |
62e76326 | 56 | |
924f73bc | 57 | class ConnStateData; |
58 | ||
de31d06f | 59 | class ClientRequestContext; |
60 | ||
62e76326 | 61 | class ClientHttpRequest |
5f8252d2 | 62 | #if ICAP_CLIENT |
63 | : public ICAPInitiator, // to start ICAP transactions | |
64 | public BodyConsumer // to receive reply bodies in request satisf. mode | |
65 | #endif | |
62e76326 | 66 | { |
67 | ||
528b2c61 | 68 | public: |
69 | void *operator new (size_t); | |
70 | void operator delete (void *); | |
528b2c61 | 71 | |
a0355e95 | 72 | ClientHttpRequest(ConnStateData::Pointer); |
528b2c61 | 73 | ~ClientHttpRequest(); |
74 | /* Not implemented - present to prevent synthetic operations */ | |
75 | ClientHttpRequest(ClientHttpRequest const &); | |
76 | ClientHttpRequest& operator=(ClientHttpRequest const &); | |
62e76326 | 77 | |
30abd221 | 78 | String rangeBoundaryStr() const; |
528b2c61 | 79 | void freeResources(); |
80 | void updateCounters(); | |
81 | void logRequest(); | |
86a2f789 | 82 | _SQUID_INLINE_ MemObject * memObject() const; |
528b2c61 | 83 | bool multipartRangeRequest() const; |
8e2745f4 | 84 | void processRequest(); |
85 | void httpStart(); | |
0655fa4d | 86 | bool onlyIfCached()const; |
87 | bool gotEnough() const; | |
86a2f789 | 88 | _SQUID_INLINE_ StoreEntry *storeEntry() const; |
89 | void storeEntry(StoreEntry *); | |
0976f8db | 90 | _SQUID_INLINE_ StoreEntry *loggingEntry() const; |
91 | void loggingEntry(StoreEntry *); | |
0655fa4d | 92 | |
a2ac85d9 | 93 | _SQUID_INLINE_ ConnStateData::Pointer getConn(); |
94 | _SQUID_INLINE_ ConnStateData::Pointer const getConn() const; | |
95 | _SQUID_INLINE_ void setConn(ConnStateData::Pointer); | |
190154cf | 96 | HttpRequest *request; /* Parsed URL ... */ |
528b2c61 | 97 | char *uri; |
98 | char *log_uri; | |
62e76326 | 99 | |
100 | struct | |
101 | { | |
47f6e231 | 102 | int64_t offset; |
103 | int64_t size; | |
62e76326 | 104 | size_t headers_sz; |
105 | } | |
106 | ||
107 | out; | |
528b2c61 | 108 | HttpHdrRangeIter range_iter; /* data for iterating thru range specs */ |
109 | size_t req_sz; /* raw request size on input, not current request size */ | |
528b2c61 | 110 | log_type logType; |
62e76326 | 111 | |
528b2c61 | 112 | struct timeval start; |
528b2c61 | 113 | AccessLogEntry al; |
62e76326 | 114 | |
115 | struct | |
116 | { | |
117 | ||
118 | unsigned int accel: | |
119 | 1; | |
120 | ||
d048c262 | 121 | unsigned int transparent: |
122 | 1; | |
123 | ||
62e76326 | 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; | |
528b2c61 | 143 | dlink_node active; |
144 | dlink_list client_stream; | |
145 | int mRangeCLen(); | |
62e76326 | 146 | |
47f6e231 | 147 | int64_t maxReplyBodySize() const; |
148 | void maxReplyBodySize(int64_t size); | |
149 | bool isReplyBodyTooLarge(int64_t len) const; | |
b51aec66 | 150 | |
de31d06f | 151 | ClientRequestContext *calloutContext; |
152 | void doCallouts(); | |
153 | ||
528b2c61 | 154 | private: |
155 | CBDATA_CLASS(ClientHttpRequest); | |
47f6e231 | 156 | int64_t maxReplyBodySize_; |
86a2f789 | 157 | StoreEntry *entry_; |
0976f8db | 158 | StoreEntry *loggingEntry_; |
a2ac85d9 | 159 | ConnStateData::Pointer conn_; |
de31d06f | 160 | |
161 | #if ICAP_CLIENT | |
162 | ||
163 | public: | |
5f8252d2 | 164 | bool startIcap(ICAPServiceRep::Pointer); |
9d4d7c5e | 165 | |
166 | // private but exposed for ClientRequestContext | |
167 | void handleIcapFailure(bool bypassable = false); | |
5f8252d2 | 168 | |
169 | private: | |
170 | // ICAPInitiator API, called by ICAPXaction | |
9d4d7c5e | 171 | virtual void noteIcapAnswer(HttpMsg *message); |
172 | virtual void noteIcapQueryAbort(bool final); | |
5f8252d2 | 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: | |
9d4d7c5e | 182 | ICAPInitiate *icapHeadSource; |
5f8252d2 | 183 | BodyPipe::Pointer icapBodySource; |
184 | ||
b044675d | 185 | bool request_satisfaction_mode; |
186 | off_t request_satisfaction_offset; | |
de31d06f | 187 | #endif |
528b2c61 | 188 | }; |
189 | ||
190 | /* client http based routines */ | |
59a1efb2 | 191 | SQUIDCEXTERN char *clientConstructTraceEcho(ClientHttpRequest *); |
98242069 | 192 | SQUIDCEXTERN ACLChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http); |
59a1efb2 | 193 | SQUIDCEXTERN int clientHttpRequestStatus(int fd, ClientHttpRequest const *http); |
8e2745f4 | 194 | SQUIDCEXTERN void clientAccessCheck(ClientHttpRequest *); |
528b2c61 | 195 | |
196 | /* ones that should be elsewhere */ | |
59a1efb2 | 197 | SQUIDCEXTERN void redirectStart(ClientHttpRequest *, RH *, void *); |
528b2c61 | 198 | |
47f6e231 | 199 | SQUIDCEXTERN void tunnelStart(ClientHttpRequest *, int64_t *, int *); |
528b2c61 | 200 | |
86a2f789 | 201 | #ifdef _USE_INLINE_ |
4b9bb50a | 202 | #include "Store.h" |
86a2f789 | 203 | #include "client_side_request.cci" |
204 | #endif | |
205 | ||
c8be6d7b | 206 | #endif /* SQUID_CLIENTSIDEREQUEST_H */ |