Merge pull request #3017 from eclipse/jetty-10.x-issue-3011-move-httpcompliance-to-config
Issue #3011 - Moving HttpCompliance to HttpConfiguration
This commit is contained in:
commit
405a6b671d
|
@ -128,7 +128,7 @@ public class SslBytesServerTest extends SslBytesTest
|
|||
@Override
|
||||
public Connection newConnection(Connector connector, EndPoint endPoint)
|
||||
{
|
||||
return configure(new HttpConnection(getHttpConfiguration(), connector, endPoint,getHttpCompliance(),isRecordHttpComplianceViolations())
|
||||
return configure(new HttpConnection(getHttpConfiguration(), connector, endPoint, isRecordHttpComplianceViolations())
|
||||
{
|
||||
@Override
|
||||
protected HttpParser newHttpParser(HttpCompliance compliance)
|
||||
|
|
|
@ -300,7 +300,7 @@ public class HTTP2CServerTest extends AbstractServerTest
|
|||
@Override
|
||||
public Connection newConnection(Connector connector, EndPoint endPoint)
|
||||
{
|
||||
HttpConnection connection = new HttpConnection(getHttpConfiguration(), connector, endPoint,getHttpCompliance(),isRecordHttpComplianceViolations())
|
||||
HttpConnection connection = new HttpConnection(getHttpConfiguration(), connector, endPoint, isRecordHttpComplianceViolations())
|
||||
{
|
||||
@Override
|
||||
public void onFillable()
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.eclipse.jetty.http.CookieCompliance;
|
||||
import org.eclipse.jetty.http.HttpCompliance;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.MultiPartFormDataCompliance;
|
||||
|
@ -72,6 +73,7 @@ public class HttpConfiguration
|
|||
private boolean _useDirectByteBuffers = false;
|
||||
private long _minRequestDataRate;
|
||||
private long _minResponseDataRate;
|
||||
private HttpCompliance _httpCompliance = HttpCompliance.RFC7230;
|
||||
private CookieCompliance _cookieCompliance = CookieCompliance.RFC6265;
|
||||
private MultiPartFormDataCompliance _multiPartCompliance = MultiPartFormDataCompliance.RFC7578;
|
||||
private boolean _notifyRemoteAsyncErrors = true;
|
||||
|
@ -548,6 +550,16 @@ public class HttpConfiguration
|
|||
_minResponseDataRate = bytesPerSecond;
|
||||
}
|
||||
|
||||
public HttpCompliance getHttpCompliance()
|
||||
{
|
||||
return _httpCompliance;
|
||||
}
|
||||
|
||||
public void setHttpCompliance(HttpCompliance _httpCompliance)
|
||||
{
|
||||
this._httpCompliance = _httpCompliance;
|
||||
}
|
||||
|
||||
public CookieCompliance getCookieCompliance()
|
||||
{
|
||||
return _cookieCompliance;
|
||||
|
|
|
@ -93,7 +93,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
return last;
|
||||
}
|
||||
|
||||
public HttpConnection(HttpConfiguration config, Connector connector, EndPoint endPoint, HttpCompliance compliance, boolean recordComplianceViolations)
|
||||
public HttpConnection(HttpConfiguration config, Connector connector, EndPoint endPoint, boolean recordComplianceViolations)
|
||||
{
|
||||
super(endPoint, connector.getExecutor());
|
||||
_config = config;
|
||||
|
@ -102,7 +102,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
_generator = newHttpGenerator();
|
||||
_channel = newHttpChannel();
|
||||
_input = _channel.getRequest().getHttpInput();
|
||||
_parser = newHttpParser(compliance);
|
||||
_parser = newHttpParser(config.getHttpCompliance());
|
||||
_recordHttpComplianceViolations = recordComplianceViolations;
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("New HTTP Connection {}", this);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import org.eclipse.jetty.http.HttpCompliance;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
|
@ -32,7 +31,6 @@ import org.eclipse.jetty.util.annotation.Name;
|
|||
public class HttpConnectionFactory extends AbstractConnectionFactory implements HttpConfiguration.ConnectionFactory
|
||||
{
|
||||
private final HttpConfiguration _config;
|
||||
private HttpCompliance _httpCompliance;
|
||||
private boolean _recordHttpComplianceViolations = false;
|
||||
|
||||
public HttpConnectionFactory()
|
||||
|
@ -41,15 +39,9 @@ public class HttpConnectionFactory extends AbstractConnectionFactory implements
|
|||
}
|
||||
|
||||
public HttpConnectionFactory(@Name("config") HttpConfiguration config)
|
||||
{
|
||||
this(config,null);
|
||||
}
|
||||
|
||||
public HttpConnectionFactory(@Name("config") HttpConfiguration config, @Name("compliance") HttpCompliance compliance)
|
||||
{
|
||||
super(HttpVersion.HTTP_1_1.asString());
|
||||
_config=config;
|
||||
_httpCompliance=compliance==null?HttpCompliance.RFC7230:compliance;
|
||||
if (config==null)
|
||||
throw new IllegalArgumentException("Null HttpConfiguration");
|
||||
addBean(_config);
|
||||
|
@ -61,28 +53,15 @@ public class HttpConnectionFactory extends AbstractConnectionFactory implements
|
|||
return _config;
|
||||
}
|
||||
|
||||
public HttpCompliance getHttpCompliance()
|
||||
{
|
||||
return _httpCompliance;
|
||||
}
|
||||
|
||||
public boolean isRecordHttpComplianceViolations()
|
||||
{
|
||||
return _recordHttpComplianceViolations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param httpCompliance String value of {@link HttpCompliance}
|
||||
*/
|
||||
public void setHttpCompliance(HttpCompliance httpCompliance)
|
||||
{
|
||||
_httpCompliance = httpCompliance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection newConnection(Connector connector, EndPoint endPoint)
|
||||
{
|
||||
HttpConnection conn = new HttpConnection(_config, connector, endPoint, _httpCompliance,isRecordHttpComplianceViolations());
|
||||
HttpConnection conn = new HttpConnection(_config, connector, endPoint, isRecordHttpComplianceViolations());
|
||||
return configure(conn, connector, endPoint);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpCompliance;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.io.ChannelEndPoint;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
|
@ -104,7 +103,7 @@ public class ExtendedServerTest extends HttpServerTestBase
|
|||
{
|
||||
public ExtendedHttpConnection(HttpConfiguration config, Connector connector, EndPoint endPoint)
|
||||
{
|
||||
super(config,connector,endPoint,HttpCompliance.RFC7230_LEGACY,false);
|
||||
super(config,connector,endPoint, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -281,7 +281,7 @@ public class GracefulStopTest
|
|||
public Connection newConnection(Connector con, EndPoint endPoint)
|
||||
{
|
||||
// Slow closing connection
|
||||
HttpConnection conn = new HttpConnection(getHttpConfiguration(), con, endPoint, getHttpCompliance(), isRecordHttpComplianceViolations())
|
||||
HttpConnection conn = new HttpConnection(getHttpConfiguration(), con, endPoint, isRecordHttpComplianceViolations())
|
||||
{
|
||||
@Override
|
||||
public void close()
|
||||
|
|
|
@ -148,12 +148,12 @@ public class HttpConnectionTest
|
|||
@Test
|
||||
public void testHttp09_NoVersion() throws Exception
|
||||
{
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setHttpCompliance(HttpCompliance.RFC2616);
|
||||
String request = "GET / HTTP/0.9\r\n\r\n";
|
||||
String response = connector.getResponse(request);
|
||||
assertThat(response, containsString("400 Bad Version"));
|
||||
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC7230);
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setHttpCompliance(HttpCompliance.RFC7230);
|
||||
request = "GET / HTTP/0.9\r\n\r\n";
|
||||
response = connector.getResponse(request);
|
||||
assertThat(response, containsString("400 Bad Version"));
|
||||
|
@ -165,7 +165,7 @@ public class HttpConnectionTest
|
|||
@Test
|
||||
public void testHttp09_NoHeaders() throws Exception
|
||||
{
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setHttpCompliance(HttpCompliance.RFC2616);
|
||||
// header looking like another request is ignored
|
||||
String request = "GET /one\r\nGET :/two\r\n\r\n";
|
||||
String response = BufferUtil.toString(connector.executeRequest(request).waitForOutput(10,TimeUnit.SECONDS));
|
||||
|
@ -179,7 +179,7 @@ public class HttpConnectionTest
|
|||
@Test
|
||||
public void testHttp09_MultipleRequests() throws Exception
|
||||
{
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setHttpCompliance(HttpCompliance.RFC2616);
|
||||
|
||||
// Verify that pipelining does not work with HTTP/0.9.
|
||||
String requests = "GET /?id=123\r\n\r\nGET /?id=456\r\n\r\n";
|
||||
|
@ -407,7 +407,7 @@ public class HttpConnectionTest
|
|||
@Test
|
||||
public void test_0_9() throws Exception
|
||||
{
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616_LEGACY);
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setHttpCompliance(HttpCompliance.RFC2616_LEGACY);
|
||||
LocalEndPoint endp = connector.executeRequest("GET /R1\n");
|
||||
endp.waitUntilClosed();
|
||||
String response=BufferUtil.toString(endp.takeOutput());
|
||||
|
|
|
@ -57,7 +57,7 @@ public class SlowClientWithPipelinedRequestTest
|
|||
@Override
|
||||
public Connection newConnection(Connector connector, EndPoint endPoint)
|
||||
{
|
||||
return configure(new HttpConnection(getHttpConfiguration(),connector,endPoint,getHttpCompliance(),isRecordHttpComplianceViolations())
|
||||
return configure(new HttpConnection(getHttpConfiguration(),connector,endPoint, isRecordHttpComplianceViolations())
|
||||
{
|
||||
@Override
|
||||
public void onFillable()
|
||||
|
|
|
@ -109,8 +109,9 @@ public class ComplianceViolations2616Test
|
|||
|
||||
HttpConfiguration config = new HttpConfiguration();
|
||||
config.setSendServerVersion(false);
|
||||
config.setHttpCompliance(HttpCompliance.RFC2616_LEGACY);
|
||||
|
||||
HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(config, HttpCompliance.RFC2616_LEGACY);
|
||||
HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(config);
|
||||
httpConnectionFactory.setRecordHttpComplianceViolations(true);
|
||||
connector = new LocalConnector(server, null, null, null, -1, httpConnectionFactory);
|
||||
|
||||
|
|
Loading…
Reference in New Issue