]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup HttpStateData::peerSupportsConnectionPinning
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 2 Mar 2017 14:09:05 +0000 (03:09 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 2 Mar 2017 14:09:05 +0000 (03:09 +1300)
* move local variable lookups and creation as late as possible. This
  speeds up a bunch of cases where those variables are never needed.

* resolve an XXX about checking Proxy-Support header contents in an
  case-insensitive way, while also simplifying the test.

src/http.cc

index ce24c6486bbffb0494d5d7ba08bc43dcc44981e3..e49cec280ff0c68df3d66d97697869ffed343953 100644 (file)
@@ -860,13 +860,9 @@ HttpStateData::proceedAfter1xx()
 /**
  * returns true if the peer can support connection pinning
 */
-bool HttpStateData::peerSupportsConnectionPinning() const
+bool
+HttpStateData::peerSupportsConnectionPinning() const
 {
-    const HttpReply *rep = entry->mem_obj->getReply();
-    const HttpHeader *hdr = &rep->header;
-    bool rc;
-    String header;
-
     if (!_peer)
         return true;
 
@@ -876,6 +872,8 @@ bool HttpStateData::peerSupportsConnectionPinning() const
     if (!_peer->connection_auth)
         return false;
 
+    const HttpReply *rep = entry->mem_obj->getReply();
+
     /*The peer supports connection pinning and the http reply status
       is not unauthorized, so the related connection can be pinned
      */
@@ -908,14 +906,10 @@ bool HttpStateData::peerSupportsConnectionPinning() const
       reply and has in its list the "Session-Based-Authentication"
       which means that the peer supports connection pinning.
      */
-    if (!hdr->has(Http::HdrType::PROXY_SUPPORT))
-        return false;
-
-    header = hdr->getStrOrList(Http::HdrType::PROXY_SUPPORT);
-    /* XXX This ought to be done in a case-insensitive manner */
-    rc = (strstr(header.termedBuf(), "Session-Based-Authentication") != NULL);
+    if (rep->header.hasListMember(Http::HdrType::PROXY_SUPPORT, "Session-Based-Authentication", ','))
+        return true;
 
-    return rc;
+    return false;
 }
 
 // Called when we parsed (and possibly adapted) the headers but