]> git.ipfire.org Git - thirdparty/squid.git/blob - src/RequestFlags.h
more RequestFlags getters/setters
[thirdparty/squid.git] / src / RequestFlags.h
1 #ifndef SQUID_REQUESTFLAGS_H_
2 #define SQUID_REQUESTFLAGS_H_
3 /*
4 * DEBUG: section 73 HTTP Request
5 * AUTHOR: Duane Wessels
6 *
7 * SQUID Web Proxy Cache http://www.squid-cache.org/
8 * ----------------------------------------------------------
9 *
10 * Squid is the result of efforts by numerous individuals from
11 * the Internet community; see the CONTRIBUTORS file for full
12 * details. Many organizations have provided support for Squid's
13 * development; see the SPONSORS file for full details. Squid is
14 * Copyrighted (C) 2001 by the Regents of the University of
15 * California; see the COPYRIGHT file for full details. Squid
16 * incorporates software developed and/or copyrighted by other
17 * sources; see the CREDITS file for full details.
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 *
33 */
34
35 class RequestFlags {
36 public:
37 RequestFlags():
38 nocache(0), ims(0), auth(0), cachable(0),
39 hierarchical(0), loopdetect(false), proxy_keepalive(false), proxying_(false),
40 refresh_(false), redirected(false), need_validation(false),
41 fail_on_validation_err(false), stale_if_hit(false), nocache_hack(false), accelerated_(false),
42 ignore_cc(false), intercepted_(false), hostVerified_(false), spoof_client_ip(false),
43 internal(false), internalclient(false), must_keepalive(false), connection_auth_wanted(false), connection_auth_disabled(false), connection_proxy_auth(false), pinned_(false),
44 canRePin_(false), authSent_(false), noDirect_(false), chunkedReply_(false),
45 streamError_(false), sslPeek_(false),
46 doneFollowXForwardedFor(!FOLLOW_X_FORWARDED_FOR),
47 sslBumped_(false), destinationIPLookedUp_(false), resetTCP_(false),
48 isRanged_(false)
49 {}
50
51 unsigned int nocache :1; ///< whether the response to this request may be READ from cache
52 unsigned int ims :1;
53 unsigned int auth :1;
54 unsigned int cachable :1; ///< whether the response to thie request may be stored in the cache
55 unsigned int hierarchical :1;
56
57 // When adding new flags, please update cloneAdaptationImmune() as needed.
58 bool resetTCP() const;
59 void setResetTCP();
60 void clearResetTCP();
61 void destinationIPLookupCompleted();
62 bool destinationIPLookedUp() const;
63 // returns a partial copy of the flags that includes only those flags
64 // that are safe for a related (e.g., ICAP-adapted) request to inherit
65 RequestFlags cloneAdaptationImmune() const;
66
67 bool isRanged() const;
68 void setRanged();
69 void clearRanged();
70
71 bool sslBumped() const { return sslBumped_; }
72 void setSslBumped(bool newValue=true) { sslBumped_=newValue; }
73 void clearSslBumpeD() { sslBumped_=false; }
74
75 bool doneFollowXFF() const { return doneFollowXForwardedFor; }
76 void setDoneFollowXFF() {
77 doneFollowXForwardedFor = true;
78 }
79 void clearDoneFollowXFF() {
80 /* do not allow clearing if FOLLOW_X_FORWARDED_FOR is unset */
81 doneFollowXForwardedFor = false || !FOLLOW_X_FORWARDED_FOR;
82 }
83
84 bool sslPeek() const { return sslPeek_; }
85 void setSslPeek() { sslPeek_=true; }
86 void clearSslPeek() { sslPeek_=false; }
87
88 bool hadStreamError() const { return streamError_; }
89 void setStreamError() { streamError_ = true; }
90 void clearStreamError() { streamError_ = false; }
91
92 bool isReplyChunked() const { return chunkedReply_; }
93 void markReplyChunked() { chunkedReply_ = true; }
94
95 void setNoDirect() { noDirect_=true; }
96 bool noDirect() const{ return noDirect_; }
97
98 bool authSent() const { return authSent_; }
99 void markAuthSent() { authSent_=true;}
100
101 bool canRePin() const { return canRePin_; }
102 void allowRepinning() { canRePin_=true; }
103
104 void markPinned() { pinned_ = true; }
105 void clearPinned() { pinned_ = false; }
106 bool pinned() const { return pinned_; }
107
108 //XXX: oddly this is set in client_side_request.cc, but never checked.
109 bool wantConnectionProxyAuth() const { return connection_proxy_auth; }
110 void requestConnectionProxyAuth() { connection_proxy_auth=true; }
111
112 void disableConnectionAuth() { connection_auth_disabled=true; }
113 bool connectionAuthDisabled() const { return connection_auth_disabled; }
114
115 void wantConnectionAuth() { connection_auth_wanted=true; }
116 bool connectionAuthWanted() const { return connection_auth_wanted; }
117
118 void setMustKeepalive() { must_keepalive = true; }
119 bool mustKeepalive() const { return must_keepalive; }
120
121 //XXX: oddly this is set in client_side_request.cc but never checked.
122 void setInternalClient() { internalclient=true;}
123
124 void markInternal() { internal=true; }
125 bool isInternal() const { return internal; }
126
127 bool spoofClientIp() const { return spoof_client_ip; }
128 void setSpoofClientIp() { spoof_client_ip = true; }
129
130 bool hostVerified() const { return hostVerified_; }
131 void markHostVerified() { hostVerified_=true; }
132
133 bool intercepted() const { return intercepted_; }
134 void markIntercepted() { intercepted_=true; }
135
136 bool ignoringCacheControl() const { return ignore_cc; }
137 void ignoreCacheControl() { ignore_cc=true; }
138
139 bool accelerated() const { return accelerated_; }
140 void markAccelerated() { accelerated_ = true; }
141
142 /* nocache_hack is only enabled if USE_HTTP_VIOLATIONS is set at build-time.
143 * Compilers will have an easy time optimizing to a NOP otherwise. */
144 void hackNocache() { if (USE_HTTP_VIOLATIONS) nocache_hack=true; }
145 bool noCacheHackEnabled() const { return USE_HTTP_VIOLATIONS && nocache_hack; }
146
147 void setStaleIfHit() { stale_if_hit=true; }
148 void clearStaleIfHit() { stale_if_hit=false; }
149 bool staleIfHit() const { return stale_if_hit; }
150
151 void setFailOnValidationError() { fail_on_validation_err=true; }
152 bool failOnValidationError() const { return fail_on_validation_err; }
153
154 bool validationNeeded() const { return need_validation; }
155 void setNeedValidation() { need_validation=true; }
156
157 bool isRedirected() const { return redirected; }
158 void markRedirected() { redirected=true; }
159
160 bool refresh() const { return refresh_; }
161 void setRefresh() { refresh_ = true; }
162
163 bool proxying() const { return proxying_; }
164 void setProxying() { proxying_ = true; }
165 void clearProxying() { proxying_ = false; }
166
167 bool proxyKeepalive() const { return proxy_keepalive; }
168 void setProxyKeepalive() { proxy_keepalive=true;}
169 void clearProxyKeepalive() { proxy_keepalive=false; }
170
171 bool loopDetect() const { return loopdetect; }
172 void setLoopDetect() { loopdetect = 1; }
173 private:
174 bool loopdetect :1;
175 bool proxy_keepalive :1;
176 bool proxying_ :1; /* this should be killed, also in httpstateflags */
177 bool refresh_ :1;
178 bool redirected :1;
179 bool need_validation :1;
180 bool fail_on_validation_err :1; ///< whether we should fail if validation fails
181 bool stale_if_hit :1; ///< reply is stale if it is a hit
182 /* for changing/ignoring no-cache requests. Unused unless USE_HTTP_VIOLATIONS */
183 bool nocache_hack :1;
184 bool accelerated_ :1; ///<request is accelerated
185 bool ignore_cc :1; ///< ignore Cache-Control
186 bool intercepted_ :1; ///< intercepted request
187 bool hostVerified_ :1; ///< whether the Host: header passed verification
188 bool spoof_client_ip :1; ///< spoof client ip if possible
189 bool internal :1;
190 bool internalclient :1;
191 bool must_keepalive :1;
192 bool connection_auth_wanted :1; /** Request wants connection oriented auth */
193 bool connection_auth_disabled :1; ///< Connection oriented auth can't be supported
194 bool connection_proxy_auth :1; ///< Request wants connection oriented auth
195 bool pinned_ :1; ///< Request sent on a pinned connection
196 bool canRePin_ :1; ///< OK to reopen a failed pinned connection
197 bool authSent_ :1; ///< Authentication was forwarded
198 /** Deny direct forwarding unless overriden by always_direct.
199 * Used in accelerator mode */
200 bool noDirect_ :1;
201 bool chunkedReply_ :1; ///< Reply with chunked transfer encoding
202 bool streamError_ :1; ///< Whether stream error has occured
203 bool sslPeek_ :1; ///< internal ssl-bump request to get server cert
204 /* doneFollowXForwardedFor is set by default to the opposite of
205 * compilation option FOLLOW_X_FORWARDED_FOR (so that it returns
206 * always "done" if the build option is disabled).
207 */
208 bool doneFollowXForwardedFor :1;
209 bool sslBumped_ :1; /**< ssl-bumped request*/
210 bool destinationIPLookedUp_:1;
211 bool resetTCP_:1; ///< request to reset the TCP stream
212 bool isRanged_ :1;
213 };
214
215 #endif /* SQUID_REQUESTFLAGS_H_ */