]> 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(0), proxy_keepalive(0), proxying(0),
40 refresh(0), redirected(0), need_validation(0),
41 fail_on_validation_err(0), stale_if_hit(0), 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 unsigned int loopdetect :1;
57 unsigned int proxy_keepalive :1;
58 unsigned int proxying :1; /* this should be killed, also in httpstateflags */
59 unsigned int refresh :1;
60 unsigned int redirected :1;
61 unsigned int need_validation :1;
62 unsigned int fail_on_validation_err :1; ///< whether we should fail if validation fails
63 unsigned int stale_if_hit :1; ///< reply is stale if it is a hit
64 /* for changing/ignoring no-cache requests. Unused unless USE_HTTP_VIOLATIONS */
65
66 // When adding new flags, please update cloneAdaptationImmune() as needed.
67 bool resetTCP() const;
68 void setResetTCP();
69 void clearResetTCP();
70 void destinationIPLookupCompleted();
71 bool destinationIPLookedUp() const;
72 // returns a partial copy of the flags that includes only those flags
73 // that are safe for a related (e.g., ICAP-adapted) request to inherit
74 RequestFlags cloneAdaptationImmune() const;
75
76 bool isRanged() const;
77 void setRanged();
78 void clearRanged();
79
80 bool sslBumped() const { return sslBumped_; }
81 void setSslBumped(bool newValue=true) { sslBumped_=newValue; }
82 void clearSslBumpeD() { sslBumped_=false; }
83
84 bool doneFollowXFF() const { return doneFollowXForwardedFor; }
85 void setDoneFollowXFF() {
86 doneFollowXForwardedFor = true;
87 }
88 void clearDoneFollowXFF() {
89 /* do not allow clearing if FOLLOW_X_FORWARDED_FOR is unset */
90 doneFollowXForwardedFor = false || !FOLLOW_X_FORWARDED_FOR;
91 }
92
93 bool sslPeek() const { return sslPeek_; }
94 void setSslPeek() { sslPeek_=true; }
95 void clearSslPeek() { sslPeek_=false; }
96
97 bool hadStreamError() const { return streamError_; }
98 void setStreamError() { streamError_ = true; }
99 void clearStreamError() { streamError_ = false; }
100
101 bool isReplyChunked() const { return chunkedReply_; }
102 void markReplyChunked() { chunkedReply_ = true; }
103
104 void setNoDirect() { noDirect_=true; }
105 bool noDirect() const{ return noDirect_; }
106
107 bool authSent() const { return authSent_; }
108 void markAuthSent() { authSent_=true;}
109
110 bool canRePin() const { return canRePin_; }
111 void allowRepinning() { canRePin_=true; }
112
113 void markPinned() { pinned_ = true; }
114 void clearPinned() { pinned_ = false; }
115 bool pinned() const { return pinned_; }
116
117 //XXX: oddly this is set in client_side_request.cc, but never checked.
118 bool wantConnectionProxyAuth() const { return connection_proxy_auth; }
119 void requestConnectionProxyAuth() { connection_proxy_auth=true; }
120
121 void disableConnectionAuth() { connection_auth_disabled=true; }
122 bool connectionAuthDisabled() const { return connection_auth_disabled; }
123
124 void wantConnectionAuth() { connection_auth_wanted=true; }
125 bool connectionAuthWanted() const { return connection_auth_wanted; }
126
127 void setMustKeepalive() { must_keepalive = true; }
128 bool mustKeepalive() const { return must_keepalive; }
129
130 //XXX: oddly this is set in client_side_request.cc but never checked.
131 void setInternalClient() { internalclient=true;}
132
133 void markInternal() { internal=true; }
134 bool isInternal() const { return internal; }
135
136 bool spoofClientIp() const { return spoof_client_ip; }
137 void setSpoofClientIp() { spoof_client_ip = true; }
138
139 bool hostVerified() const { return hostVerified_; }
140 void markHostVerified() { hostVerified_=true; }
141
142 bool intercepted() const { return intercepted_; }
143 void markIntercepted() { intercepted_=true; }
144
145 bool ignoringCacheControl() const { return ignore_cc; }
146 void ignoreCacheControl() { ignore_cc=true; }
147
148 bool accelerated() const { return accelerated_; }
149 void markAccelerated() { accelerated_ = true; }
150
151 /* nocache_hack is only enabled if USE_HTTP_VIOLATIONS is set at build-time.
152 * Compilers will have an easy time optimizing to a NOP otherwise. */
153 void hackNocache() { if (USE_HTTP_VIOLATIONS) nocache_hack=true; }
154 bool noCacheHackEnabled() const { return USE_HTTP_VIOLATIONS && nocache_hack; }
155 private:
156 bool nocache_hack :1;
157 bool accelerated_ :1; ///<request is accelerated
158 bool ignore_cc :1; ///< ignore Cache-Control
159 bool intercepted_ :1; ///< intercepted request
160 bool hostVerified_ :1; ///< whether the Host: header passed verification
161 bool spoof_client_ip :1; ///< spoof client ip if possible
162 bool internal :1;
163 bool internalclient :1;
164 bool must_keepalive :1;
165 bool connection_auth_wanted :1; /** Request wants connection oriented auth */
166 bool connection_auth_disabled :1; ///< Connection oriented auth can't be supported
167 bool connection_proxy_auth :1; ///< Request wants connection oriented auth
168 bool pinned_ :1; ///< Request sent on a pinned connection
169 bool canRePin_ :1; ///< OK to reopen a failed pinned connection
170 bool authSent_ :1; ///< Authentication was forwarded
171 /** Deny direct forwarding unless overriden by always_direct.
172 * Used in accelerator mode */
173 bool noDirect_ :1;
174 bool chunkedReply_ :1; ///< Reply with chunked transfer encoding
175 bool streamError_ :1; ///< Whether stream error has occured
176 bool sslPeek_ :1; ///< internal ssl-bump request to get server cert
177 /* doneFollowXForwardedFor is set by default to the opposite of
178 * compilation option FOLLOW_X_FORWARDED_FOR (so that it returns
179 * always "done" if the build option is disabled).
180 */
181 bool doneFollowXForwardedFor :1;
182 bool sslBumped_ :1; /**< ssl-bumped request*/
183 bool destinationIPLookedUp_:1;
184 bool resetTCP_:1; ///< request to reset the TCP stream
185 bool isRanged_ :1;
186 };
187
188 #endif /* SQUID_REQUESTFLAGS_H_ */