]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: replace HTTP Request bitmap flags with boolean
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 19 Nov 2016 07:24:46 +0000 (20:24 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 19 Nov 2016 07:24:46 +0000 (20:24 +1300)
src/HttpStateFlags.h [deleted file]
src/Makefile.am
src/RequestFlags.h
src/cf.data.pre
src/htcp.cc
src/http.cc
src/http.h
src/http/Makefile.am
src/http/StateFlags.h [new file with mode: 0644]
src/tunnel.cc

diff --git a/src/HttpStateFlags.h b/src/HttpStateFlags.h
deleted file mode 100644 (file)
index 1b357df..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#ifndef SQUID_HTTPSTATEFLAGS_H_
-#define SQUID_HTTPSTATEFLAGS_H_
-
-// POD
-class HttpStateFlags
-{
-public:
-    bool proxying:1;
-    bool keepalive:1;
-    bool only_if_cached:1;
-    bool handling1xx:1; ///< we are ignoring or forwarding 1xx response
-    bool headers_parsed:1;
-    unsigned int front_end_https:2; //XXX: huh?
-    bool originpeer:1;
-    bool keepalive_broken:1;
-    bool abuse_detected:1;
-    bool request_sent:1;
-    bool do_next_read:1;
-    bool consume_body_data:1; //XXX: seems unused
-    bool chunked:1; ///< reading a chunked response; TODO: rename
-    bool chunked_request:1; ///< writing a chunked request
-    bool sentLastChunk:1; ///< do not try to write last-chunk again
-};
-
-#endif /* SQUID_HTTPSTATEFLAGS_H_ */
-
index 5d17687e15083b2f0dc59873b6d15cbfea5aff83..f8a8a6d6b56c9f9fd9501cdc794ed0e5fb2e6ba4 100644 (file)
@@ -312,7 +312,6 @@ squid_SOURCES = \
        hier_code.h \
        HierarchyLogEntry.h \
        $(HTCPSOURCE) \
-       HttpStateFlags.h \
        http.cc \
        http.h \
        HttpHeaderFieldStat.h \
@@ -1263,7 +1262,6 @@ tests_testCacheManager_SOURCES = \
        hier_code.h \
        helper.cc \
        $(HTCPSOURCE) \
-       HttpStateFlags.h \
        http.cc \
        HttpBody.h \
        HttpBody.cc \
index ffa6d40a790d26845597000255bd5884e7a0d297..78aaf0bddc61d7955e8b3bd27788c81a10493153 100644 (file)
 
 /** request-related flags
  *
- * The bit-field contains both flags marking a request's current state,
+ * Contains both flags marking a request's current state,
  * and flags requesting some processing to be done at a later stage.
  * TODO: better distinguish the two cases.
  */
 class RequestFlags
 {
 public:
-    RequestFlags() {
-        memset(this,0,sizeof(RequestFlags));
-    }
-
     /** true if the response to this request may not be READ from cache */
-    bool noCache :1;
+    bool noCache = false;
     /** request is if-modified-since */
-    bool ims :1;
+    bool ims = false;
     /** request is authenticated */
-    bool auth :1;
+    bool auth = false;
     /** do not use keytabs for peer Kerberos authentication */
-    bool auth_no_keytab :1;
+    bool auth_no_keytab = false;
     /** he response to the request may be stored in the cache */
-    bool cachable :1;
+    bool cachable = false;
     /** the request can be forwarded through the hierarchy */
-    bool hierarchical :1;
+    bool hierarchical = false;
     /** a loop was detected on this request */
-    bool loopDetected :1;
+    bool loopDetected = false;
     /** the connection can be kept alive */
-    bool proxyKeepalive :1;
+    bool proxyKeepalive = false;
     /* this should be killed, also in httpstateflags */
-    bool proxying :1;
+    bool proxying = false;
     /** content has expired, need to refresh it */
-    bool refresh :1;
+    bool refresh = false;
     /** request was redirected by redirectors */
-    bool redirected :1;
+    bool redirected = false;
     /** the requested object needs to be validated. See client_side_reply.cc
      * for further information.
      */
-    bool needValidation :1;
+    bool needValidation = false;
     /** whether we should fail if validation fails */
-    bool failOnValidationError :1;
+    bool failOnValidationError = false;
     /** reply is stale if it is a hit */
-    bool staleIfHit :1;
+    bool staleIfHit = false;
     /** request to override no-cache directives
      *
      * always use noCacheHack() for reading.
      * \note only meaningful if USE_HTTP_VIOLATIONS is defined at build time
      */
-    bool nocacheHack :1;
+    bool nocacheHack = false;
     /** this request is accelerated (reverse-proxy) */
-    bool accelerated :1;
+    bool accelerated = false;
     /** if set, ignore Cache-Control headers */
-    bool ignoreCc :1;
+    bool ignoreCc = false;
     /** set for intercepted requests */
-    bool intercepted :1;
+    bool intercepted = false;
     /** set if the Host: header passed verification */
-    bool hostVerified :1;
+    bool hostVerified = false;
     /// Set for requests handled by a "tproxy" port.
-    bool interceptTproxy :1;
+    bool interceptTproxy = false;
     /// The client IP address should be spoofed when connecting to the web server.
     /// This applies to TPROXY traffic that has not had spoofing disabled through
     /// the spoof_client_ip squid.conf ACL.
-    bool spoofClientIp :1;
+    bool spoofClientIp = false;
     /** set if the request is internal (\see ClientHttpRequest::flags.internal)*/
-    bool internal :1;
-    /** set for internally-generated requests */
+    bool internal = false;
     //XXX this is set in in clientBeginRequest, but never tested.
-    bool internalClient :1;
+    /** set for internally-generated requests */
+    bool internalClient = false;
     /** if set, request to try very hard to keep the connection alive */
-    bool mustKeepalive :1;
+    bool mustKeepalive = false;
     /** set if the rquest wants connection oriented auth */
-    bool connectionAuth :1;
+    bool connectionAuth = false;
     /** set if connection oriented auth can not be supported */
-    bool connectionAuthDisabled :1;
-    /** Request wants connection oriented auth */
+    bool connectionAuthDisabled = false;
     // XXX This is set in clientCheckPinning but never tested
-    bool connectionProxyAuth :1;
+    /** Request wants connection oriented auth */
+    bool connectionProxyAuth = false;
     /** set if the request was sent on a pinned connection */
-    bool pinned :1;
+    bool pinned = false;
     /** Authentication was already sent upstream (e.g. due tcp-level auth) */
-    bool authSent :1;
+    bool authSent = false;
     /** Deny direct forwarding unless overriden by always_direct
      * Used in accelerator mode */
-    bool noDirect :1;
+    bool noDirect = false;
     /** Reply with chunked transfer encoding */
-    bool chunkedReply :1;
+    bool chunkedReply = false;
     /** set if stream error has occured */
-    bool streamError :1;
+    bool streamError = false;
     /** internal ssl-bump request to get server cert */
-    bool sslPeek :1;
+    bool sslPeek = false;
     /** set if X-Forwarded-For checking is complete
      *
      * do not read directly; use doneFollowXff for reading
      */
-    bool done_follow_x_forwarded_for :1;
+    bool done_follow_x_forwarded_for = false;
     /** set for ssl-bumped requests */
-    bool sslBumped :1;
+    bool sslBumped = false;
     /// carries a representation of an FTP command [received on ftp_port]
-    bool ftpNative :1;
-    bool destinationIpLookedUp:1;
+    bool ftpNative = false;
+    bool destinationIpLookedUp = false;
     /** request to reset the TCP stream */
-    bool resetTcp:1;
+    bool resetTcp = false;
     /** set if the request is ranged */
-    bool isRanged :1;
+    bool isRanged = false;
 
     /// whether to forward via TunnelStateData (instead of FwdState)
-    bool forceTunnel :1;
+    bool forceTunnel = false;
 
     /** clone the flags, resetting to default those which are not safe in
      *  a related (e.g. ICAP-adapted) request.
index 380a8a6c8d0b11e4e2e99f4c72017488a675651e..79f1e3d0dca7735b51fc7b19b5126bba7e20cd08 100644 (file)
@@ -3402,7 +3402,7 @@ DOC_START
                        certificate. If not specified the peer hostname will be
                        used.
        
-       front-end-https
+       front-end-https[=off|on|auto]
                        Enable the "Front-End-Https: On" header needed when
                        using Squid as a SSL frontend in front of Microsoft OWA.
                        See MS KB document Q307347 for details on this header.
index 686d0fd69511b78820ed9f3f2d9c56da49c1dd85..818fc512fc3c54b7a8944d4e85fd4e30d7d03766 100644 (file)
@@ -22,7 +22,6 @@
 #include "htcp.h"
 #include "http.h"
 #include "HttpRequest.h"
-#include "HttpStateFlags.h"
 #include "icmp/net_db.h"
 #include "ip/tools.h"
 #include "md5.h"
@@ -1428,7 +1427,7 @@ htcpQuery(StoreEntry * e, HttpRequest * req, CachePeer * p)
     ssize_t pktlen;
     char vbuf[32];
     HttpHeader hdr(hoRequest);
-    HttpStateFlags flags;
+    Http::StateFlags flags;
 
     if (!Comm::IsConnOpen(htcpIncomingConn))
         return 0;
@@ -1478,7 +1477,7 @@ htcpClear(StoreEntry * e, const char *uri, HttpRequest * req, const HttpRequestM
     char vbuf[32];
     HttpHeader hdr(hoRequest);
     MemBuf mb;
-    HttpStateFlags flags;
+    Http::StateFlags flags;
 
     if (!Comm::IsConnOpen(htcpIncomingConn))
         return;
index ca61909e12ea0aee91e3f15e13a75e902869ce04..f985cdc936a8c3100cabb0c49a270a98f0bf6f60 100644 (file)
@@ -41,7 +41,6 @@
 #include "HttpHeaderTools.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
-#include "HttpStateFlags.h"
 #include "log/access_log.h"
 #include "MemBuf.h"
 #include "MemObject.h"
@@ -82,7 +81,7 @@ static const char *const crlf = "\r\n";
 
 static void httpMaybeRemovePublic(StoreEntry *, Http::StatusCode);
 static void copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, const String strConnection, const HttpRequest * request,
-        HttpHeader * hdr_out, const int we_do_ranges, const HttpStateFlags &);
+        HttpHeader * hdr_out, const int we_do_ranges, const Http::StateFlags &);
 
 HttpStateData::HttpStateData(FwdState *theFwdState) :
     AsyncJob("HttpStateData"),
@@ -1662,7 +1661,7 @@ HttpStateData::doneWithServer() const
  * Fixup authentication request headers for special cases
  */
 static void
-httpFixupAuthentication(HttpRequest * request, const HttpHeader * hdr_in, HttpHeader * hdr_out, const HttpStateFlags &flags)
+httpFixupAuthentication(HttpRequest * request, const HttpHeader * hdr_in, HttpHeader * hdr_out, const Http::StateFlags &flags)
 {
     Http::HdrType header = flags.originpeer ? Http::HdrType::AUTHORIZATION : Http::HdrType::PROXY_AUTHORIZATION;
 
@@ -1768,7 +1767,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
                                       StoreEntry * entry,
                                       const AccessLogEntryPointer &al,
                                       HttpHeader * hdr_out,
-                                      const HttpStateFlags &flags)
+                                      const Http::StateFlags &flags)
 {
     /* building buffer for complex strings */
 #define BBUF_SZ (MAX_URL+32)
@@ -1958,7 +1957,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
  * to our outgoing fetch request.
  */
 void
-copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, const String strConnection, const HttpRequest * request, HttpHeader * hdr_out, const int we_do_ranges, const HttpStateFlags &flags)
+copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, const String strConnection, const HttpRequest * request, HttpHeader * hdr_out, const int we_do_ranges, const Http::StateFlags &flags)
 {
     debugs(11, 5, "httpBuildRequestHeader: " << e->name << ": " << e->value );
 
index db86ea9519e1227b534a0c38c3780512c6798c54..30a26cdb7127c3b4495cd63539bbe416cb24d1dc 100644 (file)
@@ -12,7 +12,7 @@
 #include "clients/Client.h"
 #include "comm.h"
 #include "http/forward.h"
-#include "HttpStateFlags.h"
+#include "http/StateFlags.h"
 #include "sbuf/SBuf.h"
 
 class FwdState;
@@ -30,7 +30,7 @@ public:
                                        StoreEntry * entry,
                                        const AccessLogEntryPointer &al,
                                        HttpHeader * hdr_out,
-                                       const HttpStateFlags &flags);
+                                       const Http::StateFlags &flags);
 
     virtual const Comm::ConnectionPointer & dataConnection() const;
     /* should be private */
@@ -46,7 +46,7 @@ public:
     CachePeer *_peer;       /* CachePeer request made to */
     int eof;            /* reached end-of-object? */
     int lastChunk;      /* reached last chunk of a chunk-encoded reply */
-    HttpStateFlags flags;
+    Http::StateFlags flags;
     size_t read_sz;
     SBuf inBuf;                ///< I/O buffer for receiving server responses
     bool ignoreCacheControl;
index 43ea4fa5b8c015d7605c58612e3965488a231d5c..280e16a5a2414b544b6bee273228790708fa3edf 100644 (file)
@@ -25,6 +25,7 @@ libhttp_la_SOURCES = \
        RegisteredHeadersHash.cci \
        RequestMethod.cc \
        RequestMethod.h \
+       StateFlags.h \
        StatusCode.cc \
        StatusCode.h \
        StatusLine.cc \
diff --git a/src/http/StateFlags.h b/src/http/StateFlags.h
new file mode 100644 (file)
index 0000000..1180b8a
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#ifndef SQUID_SRC_HTTP_STATEFLAGS_H
+#define SQUID_SRC_HTTP_STATEFLAGS_H
+
+namespace Http
+{
+
+class StateFlags
+{
+public:
+    unsigned int front_end_https = 0; ///< send "Front-End-Https: On" header (off/on/auto=2)
+    bool proxying = false;
+    bool keepalive = false;
+    bool only_if_cached = false;
+    bool handling1xx = false;       ///< we are ignoring or forwarding 1xx response
+    bool headers_parsed = false;
+    bool originpeer = false;
+    bool keepalive_broken = false;
+    bool abuse_detected = false;
+    bool request_sent = false;
+    bool do_next_read = false;
+    bool chunked = false;           ///< reading a chunked response; TODO: rename
+    bool chunked_request = false;   ///< writing a chunked request
+    bool sentLastChunk = false;     ///< do not try to write last-chunk again
+};
+
+} // namespace Http
+
+#endif /* SQUID_SRC_HTTP_STATEFLAGS_H */
+
index b04553df4997ff837dbe9c17908dfb489f8202fb..a823c622be4ec774f1cd815d0f80b242a470d72b 100644 (file)
@@ -28,7 +28,6 @@
 #include "http.h"
 #include "http/Stream.h"
 #include "HttpRequest.h"
-#include "HttpStateFlags.h"
 #include "ip/QosConfig.h"
 #include "LogTags.h"
 #include "MemBuf.h"
@@ -1141,7 +1140,7 @@ tunnelRelayConnectRequest(const Comm::ConnectionPointer &srv, void *data)
     TunnelStateData *tunnelState = (TunnelStateData *)data;
     assert(!tunnelState->waitingForConnectExchange());
     HttpHeader hdr_out(hoRequest);
-    HttpStateFlags flags;
+    Http::StateFlags flags;
     debugs(26, 3, HERE << srv << ", tunnelState=" << tunnelState);
     memset(&flags, '\0', sizeof(flags));
     flags.proxying = tunnelState->request->flags.proxying;