From 2a6917939a8d40a25a857892f94c48b6e02d4aaf Mon Sep 17 00:00:00 2001 From: Patrick McManus Date: Mon, 4 Aug 2014 16:54:08 -0400 Subject: [PATCH] bug 1047698 - reorder alpn/npn offer lists r=hurley --- netwerk/protocol/http/ASpdySession.cpp | 2 ++ netwerk/protocol/http/nsHttpConnection.cpp | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/netwerk/protocol/http/ASpdySession.cpp b/netwerk/protocol/http/ASpdySession.cpp index f317d67cb7d..ba3b373f715 100644 --- a/netwerk/protocol/http/ASpdySession.cpp +++ b/netwerk/protocol/http/ASpdySession.cpp @@ -67,6 +67,8 @@ ASpdySession::NewSpdySession(uint32_t version, SpdyInformation::SpdyInformation() { + // highest index of enabled protocols is the + // most preferred for ALPN negotiaton Version[0] = SPDY_VERSION_3; VersionString[0] = NS_LITERAL_CSTRING("spdy/3"); diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index 89b82fbbe69..b4b6ba701ab 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -482,17 +482,20 @@ nsHttpConnection::SetupNPNList(nsISSLSocketControl *ssl, uint32_t caps) // The first protocol is used as the fallback if none of the // protocols supported overlap with the server's list. - // In the case of overlap, matching priority is driven by - // the order of the server's advertisement. + // When using ALPN the advertised preferences are protocolArray indicies + // {1, .., N, 0} in decreasing order. + // For NPN, In the case of overlap, matching priority is driven by + // the order of the server's advertisement - with index 0 used when + // there is no match. protocolArray.AppendElement(NS_LITERAL_CSTRING("http/1.1")); if (gHttpHandler->IsSpdyEnabled() && !(caps & NS_HTTP_DISALLOW_SPDY)) { LOG(("nsHttpConnection::SetupSSL Allow SPDY NPN selection")); - for (uint32_t index = 0; index < SpdyInformation::kCount; ++index) { - if (gHttpHandler->SpdyInfo()->ProtocolEnabled(index)) + for (uint32_t index = SpdyInformation::kCount; index > 0; --index) { + if (gHttpHandler->SpdyInfo()->ProtocolEnabled(index - 1)) protocolArray.AppendElement( - gHttpHandler->SpdyInfo()->VersionString[index]); + gHttpHandler->SpdyInfo()->VersionString[index - 1]); } }