From 22beb1d02a49a5c0f5473682bb8fc2347c55dfe2 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 27 Dec 2017 14:16:23 +0100 Subject: [PATCH] Updated tests to use _LEGACY modes Signed-off-by: Greg Wilkins --- .../client/http/HttpReceiverOverHTTPTest.java | 4 ++-- .../org/eclipse/jetty/http/HttpParser.java | 7 ++++++- .../org/eclipse/jetty/http/HttpParserTest.java | 18 +++++++++--------- .../jetty/server/ExtendedServerTest.java | 2 +- .../jetty/server/HttpConnectionTest.java | 2 +- .../servlet/ComplianceViolations2616Test.java | 4 ++-- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java index ff4235943bb..7709512f1ed 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java @@ -68,8 +68,8 @@ public class HttpReceiverOverHTTPTest { return Arrays.asList( new Object[] { HttpCompliance.LEGACY }, - new Object[] { HttpCompliance.RFC2616 }, - new Object[] { HttpCompliance.RFC7230 } + new Object[] { HttpCompliance.RFC2616_LEGACY }, + new Object[] { HttpCompliance.RFC7230_LEGACY } ); } diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 68b65f9611d..d5dd19ccb8a 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -242,7 +242,12 @@ public class HttpParser private static HttpCompliance compliance() { Boolean strict = Boolean.getBoolean(__STRICT); - return strict?HttpCompliance.LEGACY:HttpCompliance.RFC7230; + if (strict) + { + LOG.warn("Deprecated property used: "+__STRICT); + return HttpCompliance.LEGACY; + } + return HttpCompliance.RFC7230; } /* ------------------------------------------------------------------------------- */ diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java index 3386a4c8cfb..e731fe4a36f 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java @@ -120,7 +120,7 @@ public class HttpParserTest ByteBuffer buffer = BufferUtil.toBuffer("GET /999\r\n"); HttpParser.RequestHandler handler = new Handler(); - HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616); + HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616_LEGACY); parseAll(parser, buffer); Assert.assertNull(_bad); @@ -149,7 +149,7 @@ public class HttpParserTest ByteBuffer buffer = BufferUtil.toBuffer("POST /222 \r\n"); HttpParser.RequestHandler handler = new Handler(); - HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616); + HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616_LEGACY); parseAll(parser, buffer); Assert.assertNull(_bad); @@ -264,7 +264,7 @@ public class HttpParserTest "\r\n"); HttpParser.RequestHandler handler = new Handler(); - HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616); + HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616_LEGACY); parseAll(parser, buffer); Assert.assertThat(_bad, Matchers.nullValue()); @@ -287,7 +287,7 @@ public class HttpParserTest "\r\n"); HttpParser.RequestHandler handler = new Handler(); - HttpParser parser = new HttpParser(handler, 4096, HttpCompliance.RFC7230); + HttpParser parser = new HttpParser(handler, 4096, HttpCompliance.RFC7230_LEGACY); parseAll(parser, buffer); Assert.assertThat(_bad, Matchers.notNullValue()); @@ -305,7 +305,7 @@ public class HttpParserTest "\r\n"); HttpParser.RequestHandler handler = new Handler(); - HttpParser parser = new HttpParser(handler, 4096, HttpCompliance.RFC7230); + HttpParser parser = new HttpParser(handler, 4096, HttpCompliance.RFC7230_LEGACY); parseAll(parser, buffer); Assert.assertThat(_bad, Matchers.notNullValue()); @@ -322,7 +322,7 @@ public class HttpParserTest "\r\n"); HttpParser.RequestHandler handler = new Handler(); - HttpParser parser = new HttpParser(handler, 4096, HttpCompliance.RFC7230); + HttpParser parser = new HttpParser(handler, 4096, HttpCompliance.RFC7230_LEGACY); parseAll(parser, buffer); Assert.assertThat(_bad, Matchers.notNullValue()); @@ -454,7 +454,7 @@ public class HttpParserTest "\r\n"); HttpParser.RequestHandler handler = new Handler(); - HttpParser parser = new HttpParser(handler,HttpCompliance.RFC7230); + HttpParser parser = new HttpParser(handler,HttpCompliance.RFC7230_LEGACY); parseAll(parser, buffer); Assert.assertThat(_bad, Matchers.containsString("Illegal character")); Assert.assertThat(_complianceViolation,Matchers.empty()); @@ -748,7 +748,7 @@ public class HttpParserTest "Connection: close\r\n" + "\r\n"); HttpParser.RequestHandler handler = new Handler(); - HttpParser parser = new HttpParser(handler, -1, HttpCompliance.RFC7230); + HttpParser parser = new HttpParser(handler, -1, HttpCompliance.RFC7230_LEGACY); parseAll(parser, buffer); Assert.assertNull(_bad); Assert.assertEquals("GET", _methodOrVersion); @@ -780,7 +780,7 @@ public class HttpParserTest "cOnNeCtIoN: ClOsE\r\n" + "\r\n"); HttpParser.RequestHandler handler = new Handler(); - HttpParser parser = new HttpParser(handler, -1, HttpCompliance.RFC7230); + HttpParser parser = new HttpParser(handler, -1, HttpCompliance.RFC7230_LEGACY); parseAll(parser, buffer); Assert.assertNull(_bad); Assert.assertEquals("GET", _methodOrVersion); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ExtendedServerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ExtendedServerTest.java index ee2af29156e..1be081cc1bc 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ExtendedServerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ExtendedServerTest.java @@ -104,7 +104,7 @@ public class ExtendedServerTest extends HttpServerTestBase { public ExtendedHttpConnection(HttpConfiguration config, Connector connector, EndPoint endPoint) { - super(config,connector,endPoint,HttpCompliance.RFC7230,false); + super(config,connector,endPoint,HttpCompliance.RFC7230_LEGACY,false); } @Override diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java index f419224e7ce..4a6608614a8 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java @@ -245,7 +245,7 @@ public class HttpConnectionTest @Test public void test_0_9() throws Exception { - connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616); + connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616_LEGACY); LocalEndPoint endp = connector.executeRequest("GET /R1\n"); endp.waitUntilClosed(); String response=BufferUtil.toString(endp.takeOutput()); diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ComplianceViolations2616Test.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ComplianceViolations2616Test.java index 17cabe80b39..413a37780cd 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ComplianceViolations2616Test.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ComplianceViolations2616Test.java @@ -110,7 +110,7 @@ public class ComplianceViolations2616Test HttpConfiguration config = new HttpConfiguration(); config.setSendServerVersion(false); - HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(config, HttpCompliance.RFC2616); + HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(config, HttpCompliance.RFC2616_LEGACY); httpConnectionFactory.setRecordHttpComplianceViolations(true); connector = new LocalConnector(server, null, null, null, -1, httpConnectionFactory); @@ -182,7 +182,7 @@ public class ComplianceViolations2616Test String response = connector.getResponse(req1.toString()); assertThat("Response status", response, containsString("HTTP/1.1 200")); - assertThat("Response headers", response, containsString("X-Http-Violation-0: No line Folding (see https://tools.ietf.org/html/rfc7230#section-3.2.4) in mode RFC2616 for")); + assertThat("Response headers", response, containsString("X-Http-Violation-0: No line Folding")); assertThat("Response body", response, containsString("[Name] = [Some Value]")); }