Fixes #2145 - Enabled h2, http/1.1 + https failed with invalid preface.

Now using HttpVersion.HTTP_1_1::is, which is case insensitive,
to find the default protocol among the negotiated protocols.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2018-03-28 19:55:58 +02:00
parent 464b74ed60
commit d68c286499
1 changed files with 14 additions and 15 deletions

View File

@ -32,7 +32,6 @@ import org.eclipse.jetty.io.ssl.SslConnection;
public abstract class NegotiatingServerConnectionFactory extends AbstractConnectionFactory
{
private final List<String> negotiatedProtocols;
private String defaultProtocol;
@ -47,7 +46,7 @@ public abstract class NegotiatingServerConnectionFactory extends AbstractConnect
{
p = p.trim();
if (!p.isEmpty())
this.negotiatedProtocols.add(p.trim());
this.negotiatedProtocols.add(p);
}
}
}
@ -75,25 +74,25 @@ public abstract class NegotiatingServerConnectionFactory extends AbstractConnect
List<String> negotiated = this.negotiatedProtocols;
if (negotiated.isEmpty())
{
// Generate list of protocols that we can negotiate
// Generate list of protocols that we can negotiate.
negotiated = connector.getProtocols().stream()
.filter(p->
{
ConnectionFactory f=connector.getConnectionFactory(p);
return !(f instanceof SslConnectionFactory)&&!(f instanceof NegotiatingServerConnectionFactory);
})
.collect(Collectors.toList());
.filter(p ->
{
ConnectionFactory f = connector.getConnectionFactory(p);
return !(f instanceof SslConnectionFactory) && !(f instanceof NegotiatingServerConnectionFactory);
})
.collect(Collectors.toList());
}
// if default protocol is not set, then it is either HTTP/1.1 or
// the first protocol given
// If default protocol is not set, then it is
// either HTTP/1.1 or the first protocol given.
String dft = defaultProtocol;
if (dft == null && !negotiated.isEmpty())
{
if (negotiated.contains(HttpVersion.HTTP_1_1.asString()))
dft = HttpVersion.HTTP_1_1.asString();
else
dft = negotiated.get(0);
dft = negotiated.stream()
.filter(HttpVersion.HTTP_1_1::is)
.findFirst()
.orElse(negotiated.get(0));
}
SSLEngine engine = null;