]>
Commit | Line | Data |
---|---|---|
c8be6d7b | 1 | |
2 | /* | |
262a0e14 | 3 | * $Id$ |
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. | |
26ac0430 | 22 | * |
c8be6d7b | 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. | |
26ac0430 | 27 | * |
c8be6d7b | 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" |
d1e045c3 | 44 | #include "base/AsyncJob.h" |
528b2c61 | 45 | |
a83c6ed6 AR |
46 | #if USE_ADAPTATION |
47 | #include "adaptation/forward.h" | |
48 | #include "adaptation/Initiator.h" | |
de31d06f | 49 | |
50 | class HttpMsg; | |
51 | #endif | |
52 | ||
c8be6d7b | 53 | /* client_side_request.c - client side request related routines (pure logic) */ |
60745f24 | 54 | extern int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t); |
c8be6d7b | 55 | |
90f396d5 | 56 | class MemObject; |
62e76326 | 57 | |
924f73bc | 58 | class ConnStateData; |
59 | ||
de31d06f | 60 | class ClientRequestContext; |
61 | ||
62e76326 | 62 | class ClientHttpRequest |
a83c6ed6 | 63 | #if USE_ADAPTATION |
e1381638 AJ |
64 | : public Adaptation::Initiator, // to start adaptation transactions |
65 | public BodyConsumer // to receive reply bodies in request satisf. mode | |
5f8252d2 | 66 | #endif |
62e76326 | 67 | { |
68 | ||
528b2c61 | 69 | public: |
70 | void *operator new (size_t); | |
71 | void operator delete (void *); | |
a83c6ed6 | 72 | #if USE_ADAPTATION |
1cf238db | 73 | void *toCbdata() { return this; } |
74 | #endif | |
75 | ClientHttpRequest(ConnStateData *); | |
528b2c61 | 76 | ~ClientHttpRequest(); |
77 | /* Not implemented - present to prevent synthetic operations */ | |
78 | ClientHttpRequest(ClientHttpRequest const &); | |
79 | ClientHttpRequest& operator=(ClientHttpRequest const &); | |
62e76326 | 80 | |
30abd221 | 81 | String rangeBoundaryStr() const; |
528b2c61 | 82 | void freeResources(); |
83 | void updateCounters(); | |
84 | void logRequest(); | |
86a2f789 | 85 | _SQUID_INLINE_ MemObject * memObject() const; |
528b2c61 | 86 | bool multipartRangeRequest() const; |
8e2745f4 | 87 | void processRequest(); |
88 | void httpStart(); | |
0655fa4d | 89 | bool onlyIfCached()const; |
90 | bool gotEnough() const; | |
86a2f789 | 91 | _SQUID_INLINE_ StoreEntry *storeEntry() const; |
92 | void storeEntry(StoreEntry *); | |
0976f8db | 93 | _SQUID_INLINE_ StoreEntry *loggingEntry() const; |
94 | void loggingEntry(StoreEntry *); | |
0655fa4d | 95 | |
1cf238db | 96 | _SQUID_INLINE_ ConnStateData * getConn(); |
97 | _SQUID_INLINE_ ConnStateData * const getConn() const; | |
98 | _SQUID_INLINE_ void setConn(ConnStateData *); | |
190154cf | 99 | HttpRequest *request; /* Parsed URL ... */ |
528b2c61 | 100 | char *uri; |
101 | char *log_uri; | |
62e76326 | 102 | |
26ac0430 | 103 | struct { |
47f6e231 | 104 | int64_t offset; |
105 | int64_t size; | |
62e76326 | 106 | size_t headers_sz; |
3d0ac046 | 107 | } out; |
62e76326 | 108 | |
528b2c61 | 109 | HttpHdrRangeIter range_iter; /* data for iterating thru range specs */ |
110 | size_t req_sz; /* raw request size on input, not current request size */ | |
528b2c61 | 111 | log_type logType; |
62e76326 | 112 | |
1cf238db | 113 | struct timeval start_time; |
528b2c61 | 114 | AccessLogEntry al; |
62e76326 | 115 | |
26ac0430 | 116 | struct { |
3d0ac046 | 117 | unsigned int accel:1; |
2ad20b4f | 118 | unsigned int intercepted:1; |
c12ca4dd | 119 | unsigned int spoof_client_ip:1; |
3d0ac046 HN |
120 | unsigned int internal:1; |
121 | unsigned int done_copying:1; | |
122 | unsigned int purging:1; | |
123 | } flags; | |
62e76326 | 124 | |
26ac0430 | 125 | struct { |
62e76326 | 126 | http_status status; |
127 | char *location; | |
3d0ac046 | 128 | } redirect; |
62e76326 | 129 | |
528b2c61 | 130 | dlink_node active; |
131 | dlink_list client_stream; | |
132 | int mRangeCLen(); | |
62e76326 | 133 | |
de31d06f | 134 | ClientRequestContext *calloutContext; |
135 | void doCallouts(); | |
136 | ||
a83c6ed6 AR |
137 | #if USE_ADAPTATION |
138 | // AsyncJob virtual methods | |
26ac0430 AJ |
139 | virtual bool doneAll() const { |
140 | return Initiator::doneAll() && | |
141 | BodyConsumer::doneAll() && false; | |
142 | } | |
1cf238db | 143 | #endif |
144 | ||
528b2c61 | 145 | private: |
146 | CBDATA_CLASS(ClientHttpRequest); | |
47f6e231 | 147 | int64_t maxReplyBodySize_; |
86a2f789 | 148 | StoreEntry *entry_; |
0976f8db | 149 | StoreEntry *loggingEntry_; |
1cf238db | 150 | ConnStateData * conn_; |
de31d06f | 151 | |
807ecef2 | 152 | #if USE_SSL |
153 | public: | |
154 | bool sslBumpNeeded() const; | |
155 | void sslBumpStart(); | |
156 | void sslBumpEstablish(comm_err_t errflag); | |
157 | #endif | |
158 | ||
a83c6ed6 | 159 | #if USE_ADAPTATION |
de31d06f | 160 | |
161 | public: | |
a22e6cd3 | 162 | void startAdaptation(const Adaptation::ServiceGroupPointer &g); |
9d4d7c5e | 163 | |
164 | // private but exposed for ClientRequestContext | |
64b66b76 | 165 | void handleAdaptationFailure(int errDetail, bool bypassable = false); |
5f8252d2 | 166 | |
167 | private: | |
16b8a262 | 168 | // Adaptation::Initiator API |
3af10ac0 AR |
169 | virtual void noteAdaptationAnswer(const Adaptation::Answer &answer); |
170 | void handleAdaptedHeader(HttpMsg *msg); | |
171 | void handleAdaptationBlock(const Adaptation::Answer &answer); | |
5f8252d2 | 172 | |
173 | // BodyConsumer API, called by BodyPipe | |
1cf238db | 174 | virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer); |
175 | virtual void noteBodyProductionEnded(BodyPipe::Pointer); | |
176 | virtual void noteBodyProducerAborted(BodyPipe::Pointer); | |
5f8252d2 | 177 | |
178 | void endRequestSatisfaction(); | |
179 | ||
180 | private: | |
4299f876 | 181 | CbcPointer<Adaptation::Initiate> virginHeadSource; |
a83c6ed6 | 182 | BodyPipe::Pointer adaptedBodySource; |
5f8252d2 | 183 | |
b044675d | 184 | bool request_satisfaction_mode; |
57d55dfa | 185 | int64_t request_satisfaction_offset; |
de31d06f | 186 | #endif |
528b2c61 | 187 | }; |
188 | ||
189 | /* client http based routines */ | |
59a1efb2 | 190 | SQUIDCEXTERN char *clientConstructTraceEcho(ClientHttpRequest *); |
c0941a6a AR |
191 | |
192 | class ACLFilledChecklist; | |
193 | SQUIDCEXTERN ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http); | |
59a1efb2 | 194 | SQUIDCEXTERN int clientHttpRequestStatus(int fd, ClientHttpRequest const *http); |
8e2745f4 | 195 | SQUIDCEXTERN void clientAccessCheck(ClientHttpRequest *); |
528b2c61 | 196 | |
197 | /* ones that should be elsewhere */ | |
59a1efb2 | 198 | SQUIDCEXTERN void redirectStart(ClientHttpRequest *, RH *, void *); |
528b2c61 | 199 | |
47f6e231 | 200 | SQUIDCEXTERN void tunnelStart(ClientHttpRequest *, int64_t *, int *); |
528b2c61 | 201 | |
32d002cb | 202 | #if _USE_INLINE_ |
4b9bb50a | 203 | #include "Store.h" |
86a2f789 | 204 | #include "client_side_request.cci" |
205 | #endif | |
206 | ||
c8be6d7b | 207 | #endif /* SQUID_CLIENTSIDEREQUEST_H */ |