From: Amos Jeffries Date: Mon, 27 Feb 2017 16:41:03 +0000 (+1300) Subject: Cleanup HttpStateData::peerSupportsConnectionPinning X-Git-Tag: M-staged-PR71~239 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f891baff1897f960538bebdc05d024be38fe4223;p=thirdparty%2Fsquid.git Cleanup HttpStateData::peerSupportsConnectionPinning * 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. --- diff --git a/src/http.cc b/src/http.cc index dd7233b7c5..625281c562 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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