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