bug 1047698 - reorder alpn/npn offer lists r=hurley

This commit is contained in:
Patrick McManus 2014-08-04 16:54:08 -04:00
parent ae16b3559d
commit 2a6917939a
2 changed files with 10 additions and 5 deletions

View File

@ -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");

View File

@ -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]);
}
}