]>
Commit | Line | Data |
---|---|---|
c8be6d7b | 1 | /* |
c8be6d7b | 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. | |
26ac0430 | 18 | * |
c8be6d7b | 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. | |
26ac0430 | 23 | * |
c8be6d7b | 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 | ||
5cc71155 | 33 | #include "AccessLogEntry.h" |
602d9612 | 34 | #include "acl/forward.h" |
a2ac85d9 | 35 | #include "client_side.h" |
602d9612 | 36 | #include "clientStream.h" |
43ca19e0 | 37 | #include "HttpHeaderRange.h" |
02c8dde5 | 38 | #include "LogTags.h" |
528b2c61 | 39 | |
a83c6ed6 AR |
40 | #if USE_ADAPTATION |
41 | #include "adaptation/forward.h" | |
42 | #include "adaptation/Initiator.h" | |
de31d06f | 43 | class HttpMsg; |
44 | #endif | |
45 | ||
c6983ec7 FC |
46 | class ClientRequestContext; |
47 | class ConnStateData; | |
90f396d5 | 48 | class MemObject; |
62e76326 | 49 | |
c6983ec7 FC |
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); | |
924f73bc | 52 | |
62e76326 | 53 | class ClientHttpRequest |
a83c6ed6 | 54 | #if USE_ADAPTATION |
e1381638 AJ |
55 | : public Adaptation::Initiator, // to start adaptation transactions |
56 | public BodyConsumer // to receive reply bodies in request satisf. mode | |
5f8252d2 | 57 | #endif |
62e76326 | 58 | { |
59 | ||
528b2c61 | 60 | public: |
be364179 | 61 | ClientHttpRequest(ConnStateData *csd); |
528b2c61 | 62 | ~ClientHttpRequest(); |
63 | /* Not implemented - present to prevent synthetic operations */ | |
64 | ClientHttpRequest(ClientHttpRequest const &); | |
65 | ClientHttpRequest& operator=(ClientHttpRequest const &); | |
62e76326 | 66 | |
30abd221 | 67 | String rangeBoundaryStr() const; |
528b2c61 | 68 | void freeResources(); |
69 | void updateCounters(); | |
70 | void logRequest(); | |
86a2f789 | 71 | _SQUID_INLINE_ MemObject * memObject() const; |
528b2c61 | 72 | bool multipartRangeRequest() const; |
8e2745f4 | 73 | void processRequest(); |
74 | void httpStart(); | |
0655fa4d | 75 | bool onlyIfCached()const; |
76 | bool gotEnough() const; | |
86a2f789 | 77 | _SQUID_INLINE_ StoreEntry *storeEntry() const; |
78 | void storeEntry(StoreEntry *); | |
0976f8db | 79 | _SQUID_INLINE_ StoreEntry *loggingEntry() const; |
80 | void loggingEntry(StoreEntry *); | |
0655fa4d | 81 | |
4063e8b1 | 82 | _SQUID_INLINE_ ConnStateData * getConn() const; |
1cf238db | 83 | _SQUID_INLINE_ void setConn(ConnStateData *); |
be364179 | 84 | |
be364179 AJ |
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 | ||
190154cf | 90 | HttpRequest *request; /* Parsed URL ... */ |
528b2c61 | 91 | char *uri; |
92 | char *log_uri; | |
a8a0b1c2 | 93 | String store_id; /* StoreID for transactions where the request member is nil */ |
62e76326 | 94 | |
26ac0430 | 95 | struct { |
47f6e231 | 96 | int64_t offset; |
97 | int64_t size; | |
62e76326 | 98 | size_t headers_sz; |
3d0ac046 | 99 | } out; |
62e76326 | 100 | |
528b2c61 | 101 | HttpHdrRangeIter range_iter; /* data for iterating thru range specs */ |
102 | size_t req_sz; /* raw request size on input, not current request size */ | |
02c8dde5 AJ |
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; | |
62e76326 | 107 | |
1cf238db | 108 | struct timeval start_time; |
41ebd397 | 109 | AccessLogEntry::Pointer al; ///< access.log entry |
62e76326 | 110 | |
26ac0430 | 111 | struct { |
be4d35dc FC |
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; | |
3d0ac046 | 118 | } flags; |
62e76326 | 119 | |
26ac0430 | 120 | struct { |
955394ce | 121 | Http::StatusCode status; |
62e76326 | 122 | char *location; |
3d0ac046 | 123 | } redirect; |
62e76326 | 124 | |
528b2c61 | 125 | dlink_node active; |
126 | dlink_list client_stream; | |
127 | int mRangeCLen(); | |
62e76326 | 128 | |
de31d06f | 129 | ClientRequestContext *calloutContext; |
130 | void doCallouts(); | |
131 | ||
a83c6ed6 AR |
132 | #if USE_ADAPTATION |
133 | // AsyncJob virtual methods | |
26ac0430 AJ |
134 | virtual bool doneAll() const { |
135 | return Initiator::doneAll() && | |
136 | BodyConsumer::doneAll() && false; | |
137 | } | |
1cf238db | 138 | #endif |
139 | ||
528b2c61 | 140 | private: |
47f6e231 | 141 | int64_t maxReplyBodySize_; |
86a2f789 | 142 | StoreEntry *entry_; |
0976f8db | 143 | StoreEntry *loggingEntry_; |
1cf238db | 144 | ConnStateData * conn_; |
de31d06f | 145 | |
807ecef2 | 146 | #if USE_SSL |
caf3666d | 147 | /// whether (and how) the request needs to be bumped |
08097970 | 148 | Ssl::BumpMode sslBumpNeed_; |
e0c0d54c | 149 | |
807ecef2 | 150 | public: |
08097970 AR |
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; } | |
e0c0d54c | 155 | /// set the sslBumpNeeded state |
08097970 | 156 | void sslBumpNeed(Ssl::BumpMode mode); |
807ecef2 | 157 | void sslBumpStart(); |
158 | void sslBumpEstablish(comm_err_t errflag); | |
159 | #endif | |
160 | ||
a83c6ed6 | 161 | #if USE_ADAPTATION |
de31d06f | 162 | |
163 | public: | |
a22e6cd3 | 164 | void startAdaptation(const Adaptation::ServiceGroupPointer &g); |
9d4d7c5e | 165 | |
166 | // private but exposed for ClientRequestContext | |
64b66b76 | 167 | void handleAdaptationFailure(int errDetail, bool bypassable = false); |
5f8252d2 | 168 | |
169 | private: | |
16b8a262 | 170 | // Adaptation::Initiator API |
3af10ac0 AR |
171 | virtual void noteAdaptationAnswer(const Adaptation::Answer &answer); |
172 | void handleAdaptedHeader(HttpMsg *msg); | |
173 | void handleAdaptationBlock(const Adaptation::Answer &answer); | |
79628299 | 174 | virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group); |
5f8252d2 | 175 | |
176 | // BodyConsumer API, called by BodyPipe | |
1cf238db | 177 | virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer); |
178 | virtual void noteBodyProductionEnded(BodyPipe::Pointer); | |
179 | virtual void noteBodyProducerAborted(BodyPipe::Pointer); | |
5f8252d2 | 180 | |
181 | void endRequestSatisfaction(); | |
0ad2b63b CT |
182 | /// called by StoreEntry when it has more buffer space available |
183 | void resumeBodyStorage(); | |
5f8252d2 | 184 | |
185 | private: | |
4299f876 | 186 | CbcPointer<Adaptation::Initiate> virginHeadSource; |
a83c6ed6 | 187 | BodyPipe::Pointer adaptedBodySource; |
5f8252d2 | 188 | |
b044675d | 189 | bool request_satisfaction_mode; |
57d55dfa | 190 | int64_t request_satisfaction_offset; |
de31d06f | 191 | #endif |
c7bf588b FC |
192 | |
193 | private: | |
f49c09b2 | 194 | CBDATA_CLASS2(ClientHttpRequest); |
528b2c61 | 195 | }; |
196 | ||
197 | /* client http based routines */ | |
8a648e8d | 198 | char *clientConstructTraceEcho(ClientHttpRequest *); |
c0941a6a | 199 | |
8a648e8d FC |
200 | ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http); |
201 | int clientHttpRequestStatus(int fd, ClientHttpRequest const *http); | |
202 | void clientAccessCheck(ClientHttpRequest *); | |
528b2c61 | 203 | |
204 | /* ones that should be elsewhere */ | |
06521a10 | 205 | void tunnelStart(ClientHttpRequest *, int64_t *, int *, const AccessLogEntry::Pointer &al); |
528b2c61 | 206 | |
32d002cb | 207 | #if _USE_INLINE_ |
86a2f789 | 208 | #include "client_side_request.cci" |
602d9612 | 209 | #include "Store.h" |
86a2f789 | 210 | #endif |
211 | ||
c8be6d7b | 212 | #endif /* SQUID_CLIENTSIDEREQUEST_H */ |