]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/HttpUpgradeProtocolAccess.h
NoNewGlobals: HttpUpgradeProtocolAccess::ProtoOther (#1745)
[thirdparty/squid.git] / src / HttpUpgradeProtocolAccess.h
index ae8a02ee116c14d05f71e61c4dab13eb1aa8cbff..a310cd86fab7e12977fa863f81290b4ceebecda3 100644 (file)
@@ -82,7 +82,7 @@ private:
     typedef std::deque<NamedGuard> NamedGuards;
 
     /// pseudonym to specify rules for "all other protocols"
-    static const SBuf ProtoOther;
+    inline static const SBuf &ProtoOther();
 
     /// rules governing upgrades to explicitly named protocols
     NamedGuards namedGuards;
@@ -98,7 +98,7 @@ HttpUpgradeProtocolAccess::forEach(const Visitor &visitor) const
     for (const auto &namedGuard: namedGuards)
         visitor(namedGuard.protocol, namedGuard.guard);
     if (other)
-        visitor(ProtoOther, other);
+        visitor(ProtoOther(), other);
 }
 
 template <typename Visitor>
@@ -114,7 +114,14 @@ HttpUpgradeProtocolAccess::forApplicable(const ProtocolView &offer, const Visito
         seenApplicable = true; // may already be true
     }
     if (!seenApplicable && other) // OTHER is applicable if named rules were not
-        (void)visitor(ProtoOther, other);
+        (void)visitor(ProtoOther(), other);
+}
+
+inline const SBuf &
+HttpUpgradeProtocolAccess::ProtoOther()
+{
+    static const auto proto = new SBuf("OTHER");
+    return *proto;
 }
 
 #endif /* SQUID_SRC_HTTPUPGRADEPROTOCOLACCESS_H */