]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/http/StateFlags.h
Allow upgrading from HTTP/1.1 to other protocols (#481)
[thirdparty/squid.git] / src / http / StateFlags.h
index 9238f615c011140968278dac2c9b60f551e74f4f..499cfc7068b484dcd2946e2b23741dac42ee9b3f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -16,12 +16,38 @@ 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 keepalive = false; ///< whether to keep the connection persistent
     bool only_if_cached = false;
-    bool handling1xx = false;       ///< we are ignoring or forwarding 1xx response
+
+    /// Whether we are processing an HTTP 1xx control message.
+    bool handling1xx = false;
+
+    /// Whether we received an HTTP 101 (Switching Protocols) control message.
+    /// Implies true handling1xx, but the serverSwitchedProtocols state is
+    /// permanent/final while handling of other control messages usually stops.
+    bool serverSwitchedProtocols = false;
+
     bool headers_parsed = false;
-    bool originpeer = false;
+
+    /// Whether the next TCP hop is a cache_peer, including originserver
+    bool peering = false;
+
+    /// Whether this request is being forwarded inside a CONNECT tunnel
+    /// through a [non-originserver] cache_peer; implies peering and toOrigin
+    bool tunneling = false;
+
+    /// Whether the next HTTP hop is an origin server, including an
+    /// originserver cache_peer. The three possible cases are:
+    /// -# a direct TCP/HTTP connection to an origin server,
+    /// -# a direct TCP/HTTP connection to an originserver cache_peer, and
+    /// -# a CONNECT tunnel through a [non-originserver] cache_peer [to an origin server]
+    /// Thus, toOrigin is false only when the HTTP request is sent over
+    ///    a direct TCP/HTTP connection to a non-originserver cache_peer.
+    bool toOrigin = false;
+
+    /// Whether the next TCP/HTTP hop is an originserver cache_peer.
+    bool toOriginPeer() const { return toOrigin && peering && !tunneling; }
+
     bool keepalive_broken = false;
     bool abuse_detected = false;
     bool request_sent = false;