case insensitive protocols

This commit is contained in:
Greg Wilkins 2014-08-07 19:00:31 +10:00
parent 55aa2a07b4
commit 6dfa452e29
6 changed files with 14 additions and 10 deletions

View File

@ -23,6 +23,7 @@ import java.lang.management.ManagementFactory;
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.deploy.PropertiesConfigurationManager;
import org.eclipse.jetty.deploy.providers.WebAppProvider;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Handler;
@ -122,7 +123,7 @@ public class LikeJettyXml
// SSL Connector
ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory,"http/1.1"),
new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(https_config));
sslConnector.setPort(8443);
server.addConnector(sslConnector);

View File

@ -18,6 +18,7 @@
package org.eclipse.jetty.embedded;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
@ -83,7 +84,7 @@ public class ManyConnectors
// We create a second ServerConnector, passing in the http configuration we just made along with the
// previously created ssl context factory. Next we set the port and a longer idle timeout.
ServerConnector https = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory,"http/1.1"),
new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(https_config));
https.setPort(8443);
https.setIdleTimeout(500000);

View File

@ -37,6 +37,7 @@ import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
@ -337,7 +338,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
{
synchronized (_factories)
{
return _factories.get(protocol);
return _factories.get(StringUtil.asciiToLowerCase(protocol));
}
}
@ -357,7 +358,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
{
synchronized (_factories)
{
String key=factory.getProtocol();
String key=StringUtil.asciiToLowerCase(factory.getProtocol());
ConnectionFactory old=_factories.remove(key);
if (old!=null)
{
@ -378,7 +379,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
{
synchronized (_factories)
{
String key=factory.getProtocol();
String key=StringUtil.asciiToLowerCase(factory.getProtocol());
if (_factories.containsKey(key))
LOG.info("{} addIfAbsent ignored {}",this,factory);
else
@ -396,7 +397,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
{
synchronized (_factories)
{
ConnectionFactory factory= _factories.remove(protocol);
ConnectionFactory factory= _factories.remove(StringUtil.asciiToLowerCase(protocol));
removeBean(factory);
return factory;
}
@ -451,7 +452,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
public void setDefaultProtocol(String defaultProtocol)
{
_defaultProtocol = defaultProtocol;
_defaultProtocol = StringUtil.asciiToLowerCase(defaultProtocol);
if (isRunning())
_defaultConnectionFactory=getConnectionFactory(_defaultProtocol);
}

View File

@ -44,7 +44,7 @@ public class HttpConnectionFactory extends AbstractConnectionFactory implements
public HttpConnectionFactory(@Name("config") HttpConfiguration config)
{
super(HttpVersion.HTTP_1_1.toString());
super(HttpVersion.HTTP_1_1.asString());
_config=config;
addBean(_config);
}

View File

@ -133,7 +133,7 @@ public class ALPNNegotiationTest extends AbstractALPNTest
@Override
public void selected(String protocol)
{
Assert.assertEquals("http/1.1", protocol);
Assert.assertEquals("http/1.1", protocol.toLowerCase());
}
});

View File

@ -22,6 +22,7 @@ import java.net.URI;
import javax.servlet.http.HttpServlet;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.SecureRequestCustomizer;
@ -100,7 +101,7 @@ public class SimpleServletServer
https_config.addCustomizer(new SecureRequestCustomizer());
// SSL Connector
connector = new ServerConnector(server,new SslConnectionFactory(sslContextFactory,"http/1.1"),new HttpConnectionFactory(https_config));
connector = new ServerConnector(server,new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),new HttpConnectionFactory(https_config));
connector.setPort(0);
}
else