You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2025/08/29 16:54:03 UTC
(tomcat) branch 10.1.x updated: Prepare for automatic formatting.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new fc12a172fe Prepare for automatic formatting.
fc12a172fe is described below
commit fc12a172fe7ae629bf90eb343765693bd8b58736
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Aug 29 17:51:50 2025 +0100
Prepare for automatic formatting.
Make formatting of HTTP requests used in tests more consistent.
---
test/jakarta/servlet/http/TestHttpServlet.java | 26 +-
.../catalina/connector/TestCoyoteAdapter.java | 9 +-
.../TestCoyoteAdapterCanonicalization.java | 4 +-
.../connector/TestCoyoteAdapterRequestFuzzing.java | 3 +-
.../catalina/connector/TestKeepAliveCount.java | 12 +-
.../catalina/connector/TestMaxConnections.java | 5 +-
.../org/apache/catalina/connector/TestRequest.java | 28 +-
.../apache/catalina/core/TestAsyncContextImpl.java | 35 +-
.../TestAsyncContextImplListenerOnComplete.java | 11 +-
.../catalina/core/TestAsyncContextIoError.java | 11 +-
.../core/TestAsyncContextStateChanges.java | 10 +-
.../apache/catalina/core/TestStandardContext.java | 11 +-
.../catalina/core/TestSwallowAbortedUploads.java | 13 +-
.../catalina/manager/TestHostManagerWebapp.java | 91 +-
.../apache/catalina/manager/TestManagerWebapp.java | 156 ++-
.../catalina/manager/TestManagerWebappSsl.java | 32 +-
.../catalina/manager/TestStatusTransformer.java | 12 +-
.../catalina/nonblocking/TestNonBlockingAPI.java | 362 ++++---
.../catalina/servlets/ServletOptionsBaseTest.java | 10 +-
.../catalina/servlets/TestDefaultServlet.java | 150 ++-
.../catalina/servlets/TestDefaultServletPut.java | 8 +-
.../catalina/servlets/TestWebdavServlet.java | 1060 +++++++++++++-------
.../catalina/valves/TestParameterLimitValve.java | 33 +-
test/org/apache/coyote/TestIoTimeouts.java | 12 +-
.../coyote/http11/TestHttp11InputBuffer.java | 44 +-
.../apache/coyote/http11/TestHttp11Processor.java | 343 +++++--
.../http11/filters/TestChunkedInputFilter.java | 323 +++---
27 files changed, 1890 insertions(+), 924 deletions(-)
diff --git a/test/jakarta/servlet/http/TestHttpServlet.java b/test/jakarta/servlet/http/TestHttpServlet.java
index fddb138f58..e79a5507b6 100644
--- a/test/jakarta/servlet/http/TestHttpServlet.java
+++ b/test/jakarta/servlet/http/TestHttpServlet.java
@@ -32,6 +32,7 @@ import jakarta.servlet.WriteListener;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.StandardContext;
@@ -280,15 +281,15 @@ public class TestHttpServlet extends TomcatBaseTest {
request.append(" HTTP/");
request.append(httpVersion);
}
- request.append(SimpleHttpClient.CRLF);
+ request.append(CRLF);
request.append("Host: localhost:8080");
- request.append(SimpleHttpClient.CRLF);
+ request.append(CRLF);
request.append("Connection: close");
- request.append(SimpleHttpClient.CRLF);
+ request.append(CRLF);
- request.append(SimpleHttpClient.CRLF);
+ request.append(CRLF);
Client client = new Client(request.toString(), "0.9".equals(httpVersion));
@@ -320,14 +321,17 @@ public class TestHttpServlet extends TomcatBaseTest {
TraceClient client = new TraceClient();
client.setPort(getPort());
+ // @formatter:off
client.setRequest(new String[] {
- "TRACE / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "X-aaa: a1, a2" + SimpleHttpClient.CRLF +
- "X-aaa: a3" + SimpleHttpClient.CRLF +
- "Cookie: c1-v1" + SimpleHttpClient.CRLF +
- "Authorization: not-a-real-credential" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF});
+ "TRACE / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "X-aaa: a1, a2" + CRLF +
+ "X-aaa: a3" + CRLF +
+ "Cookie: c1-v1" + CRLF +
+ "Authorization: not-a-real-credential" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.setUseContentLength(true);
client.connect();
diff --git a/test/org/apache/catalina/connector/TestCoyoteAdapter.java b/test/org/apache/catalina/connector/TestCoyoteAdapter.java
index 0aa87ea0ec..43107084a1 100644
--- a/test/org/apache/catalina/connector/TestCoyoteAdapter.java
+++ b/test/org/apache/catalina/connector/TestCoyoteAdapter.java
@@ -31,6 +31,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
import org.apache.catalina.startup.SimpleHttpClient;
@@ -300,8 +301,12 @@ public class TestCoyoteAdapter extends TomcatBaseTest {
}
};
- String request = "GET /async HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: a" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /async HTTP/1.1" + CRLF +
+ "Host: a" + CRLF +
+ CRLF;
+ // @formatter:on
client.setPort(getPort());
client.setRequest(new String[] {request});
diff --git a/test/org/apache/catalina/connector/TestCoyoteAdapterCanonicalization.java b/test/org/apache/catalina/connector/TestCoyoteAdapterCanonicalization.java
index 7d0e71d831..fce46a8831 100644
--- a/test/org/apache/catalina/connector/TestCoyoteAdapterCanonicalization.java
+++ b/test/org/apache/catalina/connector/TestCoyoteAdapterCanonicalization.java
@@ -180,11 +180,13 @@ public class TestCoyoteAdapterCanonicalization extends TomcatBaseTest {
tomcat.start();
Client client = new Client(tomcat.getConnector().getLocalPort(), canonicalizedURI);
+ // @formatter:off
client.setRequest(new String[] {
"GET " + requestURI + " HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
CRLF
- });
+ });
+ // @formatter:on
client.setResponseBodyEncoding(StandardCharsets.UTF_8);
client.connect();
diff --git a/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java b/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java
index f100cf8fe8..e3ff64cdc7 100644
--- a/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java
+++ b/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java
@@ -58,6 +58,7 @@ public class TestCoyoteAdapterRequestFuzzing extends TomcatBaseTest {
public static Collection<Object[]> parameters() {
List<Object[]> parameterSets = new ArrayList<>();
+ // @formatter:off
parameterSets.add(new Object[] { "GET /00 HTTP/1.1",
"Host: lÿ#" + CRLF,
"400" } );
@@ -94,7 +95,7 @@ public class TestCoyoteAdapterRequestFuzzing extends TomcatBaseTest {
"Host: localhost" + CRLF +
COOKIE_250,
"400" } );
-
+ // @formatter:on
return parameterSets;
}
diff --git a/test/org/apache/catalina/connector/TestKeepAliveCount.java b/test/org/apache/catalina/connector/TestKeepAliveCount.java
index 81f8a66a36..a30f9d322f 100644
--- a/test/org/apache/catalina/connector/TestKeepAliveCount.java
+++ b/test/org/apache/catalina/connector/TestKeepAliveCount.java
@@ -77,8 +77,11 @@ public class TestKeepAliveCount extends TomcatBaseTest {
// Send request in two parts
String[] request = new String[1];
+ // @formatter:off
request[0] =
- "GET /test HTTP/1.0" + CRLF + CRLF;
+ "GET /test HTTP/1.0" + CRLF +
+ CRLF;
+ // @formatter:on
setRequest(request);
processRequest(false); // blocks until response has been read
boolean passed = (this.readLine()==null);
@@ -100,11 +103,14 @@ public class TestKeepAliveCount extends TomcatBaseTest {
// Send request in two parts
String[] request = new String[1];
+ // @formatter:off
request[0] =
"GET /test HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
- "Connection: Keep-Alive" + CRLF+
- "Keep-Alive: 300"+ CRLF+ CRLF;
+ "Connection: Keep-Alive" + CRLF +
+ "Keep-Alive: 300"+ CRLF +
+ CRLF;
+ // @formatter:on
setRequest(request);
diff --git a/test/org/apache/catalina/connector/TestMaxConnections.java b/test/org/apache/catalina/connector/TestMaxConnections.java
index ae3d65861b..6b1e9ed693 100644
--- a/test/org/apache/catalina/connector/TestMaxConnections.java
+++ b/test/org/apache/catalina/connector/TestMaxConnections.java
@@ -94,8 +94,11 @@ public class TestMaxConnections extends TomcatBaseTest {
// Send request in two parts
String[] request = new String[1];
+ // @formatter:off
request[0] =
- "GET /test HTTP/1.0" + CRLF + CRLF;
+ "GET /test HTTP/1.0" + CRLF +
+ CRLF;
+ // @formatter:on
setRequest(request);
boolean passed = false;
processRequest(false); // blocks until response has been read
diff --git a/test/org/apache/catalina/connector/TestRequest.java b/test/org/apache/catalina/connector/TestRequest.java
index 5782057edc..dfffc747d2 100644
--- a/test/org/apache/catalina/connector/TestRequest.java
+++ b/test/org/apache/catalina/connector/TestRequest.java
@@ -207,6 +207,7 @@ public class TestRequest extends TomcatBaseTest {
// Send request in two parts
String[] request = new String[2];
if (ucChunkedHead) {
+ // @formatter:off
request[0] =
"POST http://localhost:8080/test HTTP/1.1" + CRLF +
"Host: localhost:8080" + CRLF +
@@ -216,7 +217,9 @@ public class TestRequest extends TomcatBaseTest {
CRLF +
"3" + CRLF +
"a=1" + CRLF;
+ // @formatter:on
} else {
+ // @formatter:off
request[0] =
"POST http://localhost:8080/test HTTP/1.1" + CRLF +
"Host: localhost:8080" + CRLF +
@@ -226,12 +229,15 @@ public class TestRequest extends TomcatBaseTest {
CRLF +
"3" + CRLF +
"a=1" + CRLF;
+ // @formatter:on
}
+ // @formatter:off
request[1] =
"4" + CRLF +
"&b=2" + CRLF +
"0" + CRLF +
CRLF;
+ // @formatter:on
setRequest(request);
processRequest(); // blocks until response has been read
@@ -585,20 +591,18 @@ public class TestRequest extends TomcatBaseTest {
}
// Send specified request body using method
+ // @formatter:off
String[] request = {
- (
- method + " http://localhost:" + getPort() + "/echo"
- + (null == queryString ? "" : ("?" + queryString))
- + " HTTP/1.1" + CRLF
- + "Host: localhost:" + getPort() + CRLF
- + (null == contentType ? ""
- : ("Content-Type: " + contentType + CRLF))
- + "Connection: close" + CRLF
- + (null == requestBody ? "" : "Content-Length: " + requestBody.length() + CRLF)
- + CRLF
- + (null == requestBody ? "" : requestBody)
- )
+ method + " http://localhost:" + getPort() + "/echo" +
+ (null == queryString ? "" : ("?" + queryString)) + " HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ (null == contentType ? "" : ("Content-Type: " + contentType + CRLF)) +
+ "Connection: close" + CRLF +
+ (null == requestBody ? "" : "Content-Length: " + requestBody.length() + CRLF) +
+ CRLF +
+ (null == requestBody ? "" : requestBody)
};
+ // @formatter:on
setRequest(request);
processRequest(); // blocks until response has been read
diff --git a/test/org/apache/catalina/core/TestAsyncContextImpl.java b/test/org/apache/catalina/core/TestAsyncContextImpl.java
index 5ff875281d..b14ac36d41 100644
--- a/test/org/apache/catalina/core/TestAsyncContextImpl.java
+++ b/test/org/apache/catalina/core/TestAsyncContextImpl.java
@@ -54,6 +54,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.Request;
@@ -2925,9 +2926,13 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
Bug63816Client client = new Bug63816Client();
client.setPort(getPort());
- client.setRequest(new String[] { "GET / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF});
+ // @formatter:off
+ client.setRequest(new String[] {
+ "GET / HTTP/1.1" + CRLF +
+ "Host: localhost:" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.sendRequest();
@@ -3032,26 +3037,30 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
@Test
public void testCanceledPostChunked() throws Exception {
+ // @formatter:off
doTestCanceledPost(new String[] {
- "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + SimpleHttpClient.CRLF +
- "Transfer-Encoding: Chunked" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "10" + SimpleHttpClient.CRLF +
- "This is 16 bytes" + SimpleHttpClient.CRLF
+ "POST / HTTP/1.1" + CRLF +
+ "Host: localhost:" + CRLF +
+ "Transfer-Encoding: Chunked" + CRLF +
+ CRLF +
+ "10" + CRLF +
+ "This is 16 bytes" + CRLF
});
+ // @formatter:on
}
@Test
public void testCanceledPostNoChunking() throws Exception {
+ // @formatter:off
doTestCanceledPost(new String[] {
- "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + SimpleHttpClient.CRLF +
- "Content-Length: 100" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
+ "POST / HTTP/1.1" + CRLF +
+ "Host: localhost:" + CRLF +
+ "Content-Length: 100" + CRLF +
+ CRLF +
"This is 16 bytes"
});
+ // @formatter:on
}
diff --git a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
index 8c6151244c..8233545050 100644
--- a/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
+++ b/test/org/apache/catalina/core/TestAsyncContextImplListenerOnComplete.java
@@ -37,9 +37,9 @@ import jakarta.servlet.http.HttpServletResponse;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
-import org.apache.catalina.startup.SimpleHttpClient;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.TomcatBaseTest;
@@ -96,9 +96,12 @@ public class TestAsyncContextImplListenerOnComplete extends TomcatBaseTest {
socket.connect(new InetSocketAddress("localhost", port));
try (var writer = new OutputStreamWriter(socket.getOutputStream())) {
- writer.write("GET /repro" + SimpleHttpClient.CRLF +
- "Accept: text/event-stream" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF);
+ // @formatter:off
+ writer.write(
+ "GET /repro" + CRLF +
+ "Accept: text/event-stream" + CRLF +
+ CRLF);
+ // @formatter:on
writer.flush();
}
Thread.sleep(1_000);
diff --git a/test/org/apache/catalina/core/TestAsyncContextIoError.java b/test/org/apache/catalina/core/TestAsyncContextIoError.java
index f8052d60b9..17329a7b47 100644
--- a/test/org/apache/catalina/core/TestAsyncContextIoError.java
+++ b/test/org/apache/catalina/core/TestAsyncContextIoError.java
@@ -30,6 +30,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
import org.apache.catalina.startup.SimpleHttpClient;
@@ -65,9 +66,13 @@ public class TestAsyncContextIoError extends TomcatBaseTest {
AsyncClient client = new AsyncClient();
client.setPort(getPort());
- client.setRequest(new String[] { "GET /async HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF});
+ // @formatter:off
+ client.setRequest(new String[] {
+ "GET /async HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.sendRequest();
diff --git a/test/org/apache/catalina/core/TestAsyncContextStateChanges.java b/test/org/apache/catalina/core/TestAsyncContextStateChanges.java
index df486393c1..e6c6860393 100644
--- a/test/org/apache/catalina/core/TestAsyncContextStateChanges.java
+++ b/test/org/apache/catalina/core/TestAsyncContextStateChanges.java
@@ -41,6 +41,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.TestCoyoteAdapter;
@@ -110,9 +111,12 @@ public class TestAsyncContextStateChanges extends TomcatBaseTest {
Client client = new Client();
client.setPort(getPort());
- client.setRequest(new String[] { "GET / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF});
+ // @formatter:off
+ client.setRequest(new String[] {
+ "GET / HTTP/1.1" + CRLF +
+ "Host: localhost:" + CRLF +
+ CRLF});
+ // @formatter:on
client.connect();
client.sendRequest();
diff --git a/test/org/apache/catalina/core/TestStandardContext.java b/test/org/apache/catalina/core/TestStandardContext.java
index 97bb169ceb..d00072a94b 100644
--- a/test/org/apache/catalina/core/TestStandardContext.java
+++ b/test/org/apache/catalina/core/TestStandardContext.java
@@ -52,6 +52,7 @@ import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.ContainerEvent;
import org.apache.catalina.ContainerListener;
import org.apache.catalina.Context;
@@ -79,11 +80,13 @@ import org.apache.tomcat.util.descriptor.web.LoginConfig;
public class TestStandardContext extends TomcatBaseTest {
+ // @formatter:off
private static final String REQUEST =
- "GET / HTTP/1.1\r\n" +
- "Host: anything\r\n" +
- "Connection: close\r\n" +
- "\r\n";
+ "GET / HTTP/1.1" + CRLF +
+ "Host: anything" + CRLF +
+ "Connection: close" + CRLF +
+ CRLF;
+ // @formatter:on
@Test
public void testBug46243() throws Exception {
diff --git a/test/org/apache/catalina/core/TestSwallowAbortedUploads.java b/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
index 5313f6db40..f1152b6d01 100644
--- a/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
+++ b/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
@@ -297,13 +297,17 @@ public class TestSwallowAbortedUploads extends TomcatBaseTest {
String content = new String(sb.toString().getBytes("UTF-8"),
"ASCII");
- request = new String[] { "POST http://localhost:" + getPort() + URI + " HTTP/1.1" + CRLF
+ // @formatter:off
+ request = new String[] {
+ "POST http://localhost:" + getPort() + URI + " HTTP/1.1" + CRLF
+ "Host: localhost:" + getPort() + CRLF
+ "Connection: close" + CRLF
+ "Content-Type: multipart/form-data; boundary=" + boundary + CRLF
+ "Content-Length: " + content.length() + CRLF
+ CRLF
- + content + CRLF };
+ + content + CRLF
+ };
+ // @formatter:on
setRequest(request);
processRequest(); // blocks until response has been read
@@ -390,12 +394,15 @@ public class TestSwallowAbortedUploads extends TomcatBaseTest {
String content = new String(body);
- request = new String[] { "POST http://localhost:" + getPort() + URI + " HTTP/1.1" + CRLF
+ // @formatter:off
+ request = new String[] {
+ "POST http://localhost:" + getPort() + URI + " HTTP/1.1" + CRLF
+ "Host: localhost:" + getPort() + CRLF
+ "Connection: close" + CRLF
+ "Content-Length: " + content.length() + CRLF
+ CRLF
+ content + CRLF };
+ // @formatter:on
setRequest(request);
processRequest(); // blocks until response has been read
diff --git a/test/org/apache/catalina/manager/TestHostManagerWebapp.java b/test/org/apache/catalina/manager/TestHostManagerWebapp.java
index bd52f5c85f..c62e575276 100644
--- a/test/org/apache/catalina/manager/TestHostManagerWebapp.java
+++ b/test/org/apache/catalina/manager/TestHostManagerWebapp.java
@@ -81,108 +81,152 @@ public class TestHostManagerWebapp extends TomcatBaseTest {
client.setPort(getPort());
String basicHeader = (new BasicAuthHeader("Basic", "admin", "sekr3t")).getHeader().toString();
+ // @formatter:off
client.setRequest(new String[] {
"GET / HTTP/1.1" + CRLF +
"Host: newhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+ // @formatter:off
client.setRequest(new String[] {
"GET /host-manager/html HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/host-manager/css/manager.css"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /host-manager/text/list HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("[localhost]:[]"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /host-manager/text/add?name=newhost&aliases=bar&manager=true HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("[newhost]"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /host-manager/text/list HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("[newhost]:[bar]"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/list HTTP/1.1" + CRLF +
"Host: newhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/manager:running"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /host-manager/text/stop?name=newhost HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("[newhost]"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/list HTTP/1.1" + CRLF +
"Host: newhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("Hello"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /host-manager/text/start?name=newhost HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("[newhost]"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/list HTTP/1.1" + CRLF +
"Host: bar" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/manager:running"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /host-manager/text/persist HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -198,39 +242,55 @@ public class TestHostManagerWebapp extends TomcatBaseTest {
}
Assert.assertTrue(serverXmlDump.contains("<Alias>bar</Alias>"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /host-manager/text/remove?name=newhost HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("[newhost]"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/list HTTP/1.1" + CRLF +
"Host: newhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("Hello"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /host-manager/text/start?name=newhost HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("[newhost]"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/list HTTP/1.1" + CRLF +
"Host: newhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -238,5 +298,4 @@ public class TestHostManagerWebapp extends TomcatBaseTest {
tomcat.stop();
}
-
}
diff --git a/test/org/apache/catalina/manager/TestManagerWebapp.java b/test/org/apache/catalina/manager/TestManagerWebapp.java
index 270ca63551..388541e4ba 100644
--- a/test/org/apache/catalina/manager/TestManagerWebapp.java
+++ b/test/org/apache/catalina/manager/TestManagerWebapp.java
@@ -87,109 +87,153 @@ public class TestManagerWebapp extends TomcatBaseTest {
client.setPort(getPort());
String basicHeader = (new BasicAuthHeader("Basic", "admin", "sekr3t")).getHeader().toString();
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/html HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_UNAUTHORIZED, client.getStatusCode());
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/html HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/manager/css/manager.css"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/status HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("MiB"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/jmxproxy HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("Tomcat:type=ThreadPool,name="));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains(" - "));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/sessions?path=/manager HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("[1]"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/resources HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains(" - "));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/serverinfo HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("[Apache Tomcat"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/vminfo HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("vmName: "));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/threaddump HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("http-"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/list HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -246,74 +290,106 @@ public class TestManagerWebapp extends TomcatBaseTest {
appDir = new File(webappDir, "examples");
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/deploy?war=" + URLEncoder.QUERY.encode(appDir.getAbsolutePath(), StandardCharsets.UTF_8) + " HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("OK - "));
+ // @formatter:off
client.setRequest(new String[] {
"GET /examples/servlets/servlet/RequestInfoExample HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/examples/servlets/servlet/RequestInfoExample"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/stop?path=/examples HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+ // @formatter:off
client.setRequest(new String[] {
"GET /examples/servlets/servlet/RequestInfoExample HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NOT_FOUND, client.getStatusCode());
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/start?path=/examples HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+ // @formatter:off
client.setRequest(new String[] {
"GET /examples/servlets/servlet/RequestInfoExample HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/examples/servlets/servlet/RequestInfoExample"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/save HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/save?path=/examples HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -329,68 +405,96 @@ public class TestManagerWebapp extends TomcatBaseTest {
}
Assert.assertTrue(serverXmlDump.contains("StoreConfigLifecycleListener"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/reload?path=/examples HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/list HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/examples:running"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /examples/servlets/servlet/RequestInfoExample HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/examples/servlets/servlet/RequestInfoExample"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/list HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/examples:running"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/undeploy?path=/examples HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/list HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertFalse(client.getResponseBody().contains("/examples:running"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/findleaks?statusLine=true HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
diff --git a/test/org/apache/catalina/manager/TestManagerWebappSsl.java b/test/org/apache/catalina/manager/TestManagerWebappSsl.java
index fe8aed4fe5..51caba7c04 100644
--- a/test/org/apache/catalina/manager/TestManagerWebappSsl.java
+++ b/test/org/apache/catalina/manager/TestManagerWebappSsl.java
@@ -122,59 +122,77 @@ public class TestManagerWebappSsl extends TomcatBaseTest {
client.setPort(connector.getLocalPort());
String basicHeader = (new BasicAuthHeader("Basic", "admin", "sekr3t")).getHeader().toString();
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/sslConnectorCiphers HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains(" -"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/sslConnectorCerts HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("Subject: CN=localhost"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/sslConnectorTrustedCerts HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertFalse(client.getResponseBody().contains("Subject: CN=localhost"));
Assert.assertTrue(client.getResponseBody().contains("Subject: CN=Apache Tomcat Test CA"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/sslReload HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains(" -"));
+ // @formatter:off
client.setRequest(new String[] {
"GET /manager/text/sslConnectorCerts HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Authorization: " + basicHeader + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("Subject: CN=localhost"));
Assert.assertTrue(res.toString().indexOf("<a href=\"../helloworld.html\">") > 0);
-
}
-
}
diff --git a/test/org/apache/catalina/manager/TestStatusTransformer.java b/test/org/apache/catalina/manager/TestStatusTransformer.java
index c92f67a7df..0d9dbc8dfe 100644
--- a/test/org/apache/catalina/manager/TestStatusTransformer.java
+++ b/test/org/apache/catalina/manager/TestStatusTransformer.java
@@ -82,10 +82,14 @@ public class TestStatusTransformer extends TomcatBaseTest {
}
};
client.setPort(getPort());
+ // @formatter:off
client.setRequest(new String[] {
"GET /index.html HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
@@ -100,10 +104,14 @@ public class TestStatusTransformer extends TomcatBaseTest {
default:
requestline = "GET /status/all HTTP/1.1";
}
+ // @formatter:off
client.setRequest(new String[] {
requestline + CRLF +
"Host: localhost" + CRLF +
- "Connection: Close" + CRLF + CRLF });
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
String body = client.getResponseBody();
diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index dc8d66e45d..2d02de8493 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -55,6 +55,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.AsyncContextImpl;
@@ -159,11 +160,14 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedNoSplits() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -171,12 +175,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitBeforeChunkHeader() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
"",
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -184,12 +191,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInChunkHeader() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
"1",
- "4" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "4" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -197,12 +207,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterChunkHeader() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
"14",
- SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -210,12 +223,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInHeaderCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
"14\r",
"\n" +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -223,11 +239,14 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterHeaderCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF,
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "14" + CRLF,
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -235,12 +254,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitBeforeExtensionDelimiter() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
"14",
- ";a=b" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ ";a=b" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -248,12 +270,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterExtensionDelimiter() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
"14;",
- "a=b" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "a=b" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -261,12 +286,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInExtension() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
"14;a",
- "=b" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "=b" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -274,12 +302,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterExtension() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
"14;a=b",
- SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -287,12 +318,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInChunkBody() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
"012345",
- "678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "678901FINISHED" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -300,12 +334,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitBeforeChunkBodyCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
"012345678901FINISHED",
- SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -313,12 +350,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInChunkBodyCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
"012345678901FINISHED\r",
"\n" +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -326,11 +366,14 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterChunkBodyCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF,
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF,
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -338,12 +381,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitBeforeEndChunkCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
"0",
- SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -351,13 +397,16 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInEndChunkCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
"0" +
"\r",
"\n" +
- SimpleHttpClient.CRLF};
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -365,12 +414,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterEndChunkCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
"0" +
- SimpleHttpClient.CRLF,
- SimpleHttpClient.CRLF};
+ CRLF,
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -378,12 +430,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitBeforeTrailer() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF,
- TRAILER_HEADER_NAME + ": " + TRAILER_HEADER_VALUE + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF,
+ TRAILER_HEADER_NAME + ": " + TRAILER_HEADER_VALUE + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody, TRAILER_HEADER_VALUE);
}
@@ -391,13 +446,16 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInTrailerName() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
"x-te",
- "st" + ": " + TRAILER_HEADER_VALUE + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "st" + ": " + TRAILER_HEADER_VALUE + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody, TRAILER_HEADER_VALUE);
}
@@ -405,13 +463,16 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterTrailerName() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
TRAILER_HEADER_NAME,
- ": " + TRAILER_HEADER_VALUE + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ ": " + TRAILER_HEADER_VALUE + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody, TRAILER_HEADER_VALUE);
}
@@ -419,13 +480,16 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterTrailerDelimiter() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
TRAILER_HEADER_NAME + ":",
- " " + TRAILER_HEADER_VALUE + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ " " + TRAILER_HEADER_VALUE + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody, TRAILER_HEADER_VALUE);
}
@@ -433,13 +497,16 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitBeforeTrailerValue() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
TRAILER_HEADER_NAME + ": ",
- TRAILER_HEADER_VALUE + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ TRAILER_HEADER_VALUE + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody, TRAILER_HEADER_VALUE);
}
@@ -447,13 +514,16 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInTrailerValue() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
TRAILER_HEADER_NAME + ": abc",
- "de" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "de" + CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody, TRAILER_HEADER_VALUE);
}
@@ -461,13 +531,16 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterTrailerValue() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
TRAILER_HEADER_NAME + ": " + TRAILER_HEADER_VALUE,
- SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ CRLF +
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody, TRAILER_HEADER_VALUE);
}
@@ -475,13 +548,16 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInTrailerCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
TRAILER_HEADER_NAME + ": " + TRAILER_HEADER_VALUE + "\r",
"\n" +
- SimpleHttpClient.CRLF};
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody, TRAILER_HEADER_VALUE);
}
@@ -489,12 +565,15 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitAfterTrailerCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- TRAILER_HEADER_NAME + ": " + TRAILER_HEADER_VALUE + SimpleHttpClient.CRLF,
- SimpleHttpClient.CRLF};
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ TRAILER_HEADER_NAME + ": " + TRAILER_HEADER_VALUE + CRLF,
+ CRLF
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody, TRAILER_HEADER_VALUE);
}
@@ -502,13 +581,16 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitInFinalCrlf() throws Exception {
+ // @formatter:off
String[] requestBody = new String[] {
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
"0" +
- SimpleHttpClient.CRLF +
+ CRLF +
"\r",
- "\n"};
+ "\n"
+ };
+ // @formatter:on
doTestNonBlockingReadChunked(requestBody);
}
@@ -516,12 +598,14 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testNonBlockingReadChunkedSplitMaximum() throws Exception {
+ // @formatter:off
String requestBody = new String(
- "14" + SimpleHttpClient.CRLF +
- "012345678901FINISHED" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- TRAILER_HEADER_NAME + ": " + TRAILER_HEADER_VALUE + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF);
+ "14" + CRLF +
+ "012345678901FINISHED" + CRLF +
+ "0" + CRLF +
+ TRAILER_HEADER_NAME + ": " + TRAILER_HEADER_VALUE + CRLF +
+ CRLF);
+ // @formatter:on
String[] requestBodySplit = new String[requestBody.length()];
for (int i = 0; i < requestBody.length(); i++) {
@@ -553,12 +637,14 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
tomcat.start();
// Add the headers to the first part of the chunked body
+ // @formatter:off
requestBody[0] =
- "GET / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost" + getPort() + SimpleHttpClient.CRLF +
- "Transfer-Encoding: chunked" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
+ "GET / HTTP/1.1" + CRLF +
+ "Host: localhost" + getPort() + CRLF +
+ "Transfer-Encoding: chunked" + CRLF +
+ CRLF +
requestBody[0];
+ // @formatter:on
Client client = new Client();
client.setPort(getPort());
@@ -1764,26 +1850,30 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
@Test
public void testCanceledPostChunked() throws Exception {
+ // @formatter:off
doTestCanceledPost(new String[] {
- "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + SimpleHttpClient.CRLF +
- "Transfer-Encoding: Chunked" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "10" + SimpleHttpClient.CRLF +
- "This is 16 bytes" + SimpleHttpClient.CRLF
+ "POST / HTTP/1.1" + CRLF +
+ "Host: localhost:" + CRLF +
+ "Transfer-Encoding: Chunked" + CRLF +
+ CRLF +
+ "10" + CRLF +
+ "This is 16 bytes" + CRLF
});
+ // @formatter:on
}
@Test
public void testCanceledPostNoChunking() throws Exception {
+ // @formatter:off
doTestCanceledPost(new String[] {
- "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + SimpleHttpClient.CRLF +
- "Content-Length: 100" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
+ "POST / HTTP/1.1" + CRLF +
+ "Host: localhost:" + CRLF +
+ "Content-Length: 100" + CRLF +
+ CRLF +
"This is 16 bytes"
});
+ // @formatter:on
}
@@ -2005,11 +2095,13 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
ResponseOKClient client = new ResponseOKClient();
client.setPort(getPort());
+ // @formatter:off
client.setRequest(new String[] {
- "GET / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF
+ "GET / HTTP/1.1" + CRLF +
+ "Host: localhost:" + CRLF +
+ CRLF
});
+ // @formatter:on
client.connect();
client.sendRequest();
diff --git a/test/org/apache/catalina/servlets/ServletOptionsBaseTest.java b/test/org/apache/catalina/servlets/ServletOptionsBaseTest.java
index d23bbb80ef..b1229a4fb9 100644
--- a/test/org/apache/catalina/servlets/ServletOptionsBaseTest.java
+++ b/test/org/apache/catalina/servlets/ServletOptionsBaseTest.java
@@ -94,11 +94,14 @@ public abstract class ServletOptionsBaseTest extends TomcatBaseTest {
OptionsHttpClient client = new OptionsHttpClient();
client.setPort(getPort());
+ // @formatter:off
client.setRequest(new String[] {
"OPTIONS /webdav/" + url + " HTTP/1.1" + CRLF +
"Host: localhost:" + getPort() + CRLF +
"Connection: close" + CRLF +
- CRLF });
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
@@ -109,11 +112,14 @@ public abstract class ServletOptionsBaseTest extends TomcatBaseTest {
client.disconnect();
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
method + " /webdav/" + url + " HTTP/1.1" + CRLF +
"Host: localhost:" + getPort() + CRLF +
"Connection: close" + CRLF +
- CRLF });
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
diff --git a/test/org/apache/catalina/servlets/TestDefaultServlet.java b/test/org/apache/catalina/servlets/TestDefaultServlet.java
index 4bde3703ce..cdd4da5634 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServlet.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServlet.java
@@ -211,11 +211,15 @@ public class TestDefaultServlet extends TomcatBaseTest {
TestCompressedClient client = new TestCompressedClient(getPort());
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /index.html HTTP/1.1" + CRLF +
- "Host: localhost" + CRLF +
- "Connection: Close" + CRLF +
- "Accept-Encoding: br, gzip" + CRLF + CRLF });
+ "Host: localhost" + CRLF +
+ "Connection: Close" + CRLF +
+ "Accept-Encoding: br, gzip" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse200());
@@ -225,10 +229,14 @@ public class TestDefaultServlet extends TomcatBaseTest {
Assert.assertTrue(responseHeaders.contains("vary: accept-encoding"));
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /index.html HTTP/1.1" + CRLF +
- "Host: localhost" + CRLF +
- "Connection: Close" + CRLF+ CRLF });
+ "Host: localhost" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse200());
@@ -266,11 +274,15 @@ public class TestDefaultServlet extends TomcatBaseTest {
TestCompressedClient client = new TestCompressedClient(getPort());
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /index.html HTTP/1.1" + CRLF +
- "Host: localhost" + CRLF +
- "Connection: Close" + CRLF +
- "Accept-Encoding: br, gzip ; q = 0.5 , custom" + CRLF + CRLF });
+ "Host: localhost" + CRLF +
+ "Connection: Close" + CRLF +
+ "Accept-Encoding: br, gzip ; q = 0.5 , custom" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse200());
@@ -280,11 +292,14 @@ public class TestDefaultServlet extends TomcatBaseTest {
Assert.assertTrue(responseHeaders.contains("vary: accept-encoding"));
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /index.html HTTP/1.1" + CRLF +
- "Host: localhost" + CRLF +
- "Connection: Close" + CRLF +
- "Accept-Encoding: br;q=1,gzip,custom" + CRLF + CRLF });
+ "Host: localhost" + CRLF +
+ "Connection: Close" + CRLF +
+ "Accept-Encoding: br;q=1,gzip,custom" + CRLF +
+ CRLF });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse200());
@@ -322,11 +337,15 @@ public class TestDefaultServlet extends TomcatBaseTest {
TestCompressedClient client = new TestCompressedClient(getPort());
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /index.html HTTP/1.1" + CRLF +
- "Host: localhost" + CRLF +
- "Connection: Close" + CRLF +
- "Accept-Encoding: gzip;q=0.9,*" + CRLF + CRLF });
+ "Host: localhost" + CRLF +
+ "Connection: Close" + CRLF +
+ "Accept-Encoding: gzip;q=0.9,*" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse200());
@@ -336,11 +355,15 @@ public class TestDefaultServlet extends TomcatBaseTest {
Assert.assertTrue(responseHeaders.contains("vary: accept-encoding"));
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /index.html HTTP/1.1" + CRLF +
- "Host: localhost" + CRLF +
- "Connection: Close" + CRLF +
- "Accept-Encoding: gzip;q=0.9,br;q=0,identity," + CRLF + CRLF });
+ "Host: localhost" + CRLF +
+ "Connection: Close" + CRLF +
+ "Accept-Encoding: gzip;q=0.9,br;q=0,identity," + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse200());
@@ -377,11 +400,15 @@ public class TestDefaultServlet extends TomcatBaseTest {
// Firefox 45 Accept-Encoding
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /index.html HTTP/1.1" + CRLF +
- "Host: localhost" + CRLF +
- "Connection: Close" + CRLF +
- "Accept-Encoding: gzip, deflate, br" + CRLF + CRLF });
+ "Host: localhost" + CRLF +
+ "Connection: Close" + CRLF +
+ "Accept-Encoding: gzip, deflate, br" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse200());
@@ -392,11 +419,15 @@ public class TestDefaultServlet extends TomcatBaseTest {
// Chrome 50 Accept-Encoding
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /index.html HTTP/1.1" + CRLF +
- "Host: localhost" + CRLF +
- "Connection: Close" + CRLF +
- "Accept-Encoding: gzip, deflate, sdch, br" + CRLF + CRLF });
+ "Host: localhost" + CRLF +
+ "Connection: Close" + CRLF +
+ "Accept-Encoding: gzip, deflate, sdch, br" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse200());
@@ -506,8 +537,12 @@ public class TestDefaultServlet extends TomcatBaseTest {
new TestCustomErrorClient(tomcat.getConnector().getLocalPort());
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
- "GET /MyApp/missing HTTP/1.0" +CRLF + CRLF });
+ "GET /MyApp/missing HTTP/1.0" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse404());
@@ -522,11 +557,15 @@ public class TestDefaultServlet extends TomcatBaseTest {
// https://bz.apache.org/bugzilla/show_bug.cgi?id=50413
//
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /MyApp/missing HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Connection: close" + CRLF +
- "If-Modified-Since: " + tomorrow + CRLF + CRLF });
+ "If-Modified-Since: " + tomorrow + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse404());
@@ -535,11 +574,15 @@ public class TestDefaultServlet extends TomcatBaseTest {
// https://bz.apache.org/bugzilla/show_bug.cgi?id=50413#c6
//
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
"GET /MyApp/missing HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Connection: close" + CRLF +
- "Range: bytes=0-100" + CRLF + CRLF });
+ "Range: bytes=0-100" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse404());
@@ -562,15 +605,17 @@ public class TestDefaultServlet extends TomcatBaseTest {
File webxml = new File(appDir, "WEB-INF/web.xml");
try (FileOutputStream fos = new FileOutputStream(webxml);
Writer w = new OutputStreamWriter(fos, "UTF-8")) {
- w.write("<?xml version='1.0' encoding='UTF-8'?>\n"
- + "<web-app xmlns='http://java.sun.com/xml/ns/j2ee' "
- + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
- + " xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee "
- + " http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd'"
- + " version='2.4'>\n"
- + "<error-page>\n<error-code>404</error-code>\n"
- + "<location>/404-absent.html</location>\n</error-page>\n"
- + "</web-app>\n");
+ // @formatter:off
+ w.write("<?xml version='1.0' encoding='UTF-8'?>\n" +
+ "<web-app xmlns='http://java.sun.com/xml/ns/j2ee' " +
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
+ " xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee " +
+ " http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd'" +
+ " version='2.4'>\n" +
+ "<error-page>\n<error-code>404</error-code>\n" +
+ "<location>/404-absent.html</location>\n</error-page>\n" +
+ "</web-app>\n");
+ // @formatter:on
}
Tomcat tomcat = getTomcatInstance();
@@ -582,8 +627,12 @@ public class TestDefaultServlet extends TomcatBaseTest {
new TestCustomErrorClient(tomcat.getConnector().getLocalPort());
client.reset();
+ // @formatter:off
client.setRequest(new String[] {
- "GET /MyApp/missing HTTP/1.0" + CRLF + CRLF });
+ "GET /MyApp/missing HTTP/1.0" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest();
Assert.assertTrue(client.isResponse404());
@@ -690,25 +739,32 @@ public class TestDefaultServlet extends TomcatBaseTest {
TestCompressedClient client = new TestCompressedClient(getPort());
- client.setRequest(new String[] { "GET / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "GET / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Accept-Language: fr-FR, fr, en" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("Taille"));
Assert.assertTrue(client.getResponseBody().contains("<tt>bug43nnn/"));
- client.setRequest(new String[] { "GET /bug43nnn/ HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Accept-Language: fr-FR, fr, en" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "GET /bug43nnn/ HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Accept-Language: fr-FR, fr, en" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
-
}
}
diff --git a/test/org/apache/catalina/servlets/TestDefaultServletPut.java b/test/org/apache/catalina/servlets/TestDefaultServletPut.java
index 0255819497..2b2d159bae 100644
--- a/test/org/apache/catalina/servlets/TestDefaultServletPut.java
+++ b/test/org/apache/catalina/servlets/TestDefaultServletPut.java
@@ -140,13 +140,15 @@ public class TestDefaultServletPut extends TomcatBaseTest {
// Full PUT
PutClient putClient = new PutClient(getPort());
+ // @formatter:off
putClient.setRequest(new String[] {
"PUT /test.txt HTTP/1.1" + CRLF +
"Host: localhost:" + getPort() + CRLF +
"Content-Length: " + START_LEN + CRLF +
CRLF +
START_TEXT
- });
+ });
+ // @formatter:on
putClient.connect();
putClient.processRequest(false);
Assert.assertTrue(putClient.isResponse201());
@@ -156,6 +158,7 @@ public class TestDefaultServletPut extends TomcatBaseTest {
// Partial PUT
putClient.connect();
+ // @formatter:off
putClient.setRequest(new String[] {
"PUT /test.txt HTTP/1.1" + CRLF +
"Host: localhost:" + getPort() + CRLF +
@@ -163,7 +166,8 @@ public class TestDefaultServletPut extends TomcatBaseTest {
"Content-Length: " + PATCH_LEN + CRLF +
CRLF +
PATCH_TEXT
- });
+ });
+ // @formatter:on
putClient.processRequest(false);
if (contentRangeHeaderValid == null) {
// Not present (so will do a full PUT, replacing the existing)
diff --git a/test/org/apache/catalina/servlets/TestWebdavServlet.java b/test/org/apache/catalina/servlets/TestWebdavServlet.java
index 6867c38cf2..2bd5b2ca6f 100644
--- a/test/org/apache/catalina/servlets/TestWebdavServlet.java
+++ b/test/org/apache/catalina/servlets/TestWebdavServlet.java
@@ -33,6 +33,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
import org.apache.catalina.servlets.WebdavServlet.PropertyStore;
@@ -221,9 +222,13 @@ public class TestWebdavServlet extends TomcatBaseTest {
Client client = new Client();
client.setPort(getPort());
- client.setRequest(new String[] { "PROPFIND /bug66609/ HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF});
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND /bug66609/ HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.sendRequest();
@@ -236,6 +241,7 @@ public class TestWebdavServlet extends TomcatBaseTest {
private static final String CONTENT = "FOOBAR";
+ // @formatter:off
private static final String LOCK_BODY =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
"<D:lockinfo xmlns:D='DAV:'>\n" +
@@ -283,6 +289,7 @@ public class TestWebdavServlet extends TomcatBaseTest {
" <D:prop><T:othercustomprop/></D:prop>\n" +
" </D:remove>\n" +
"</D:propertyupdate>";
+ // @formatter:on
@Test
public void testBasicProperties() throws Exception {
@@ -304,61 +311,90 @@ public class TestWebdavServlet extends TomcatBaseTest {
client.setPort(getPort());
// Create a test file
- client.setRequest(new String[] { "PUT /file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
// Add lock to check for lock discovery
- client.setRequest(new String[] { "LOCK /file2.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /file2.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("urn:uuid:"));
- client.setRequest(new String[] { "PROPFIND / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("urn:uuid:"));
- client.setRequest(new String[] { "PROPPATCH /file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + PROPPATCH_PROPNAME.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + PROPPATCH_PROPNAME });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPPATCH /file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + PROPPATCH_PROPNAME.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ PROPPATCH_PROPNAME
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("<T:othercustomprop"));
validateXml(client.getResponseBody());
- client.setRequest(new String[] { "PROPFIND /file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + PROPFIND_PROPNAME.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + PROPFIND_PROPNAME });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND /file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + PROPFIND_PROPNAME.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ PROPFIND_PROPNAME
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("<D:getcontenttype/>"));
- client.setRequest(new String[] { "PROPFIND /file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + PROPFIND_PROP.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + PROPFIND_PROP });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND /file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + PROPFIND_PROP.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ PROPFIND_PROP
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
@@ -366,20 +402,29 @@ public class TestWebdavServlet extends TomcatBaseTest {
Assert.assertFalse(client.getResponseBody().contains("<D:getlastmodified>"));
Assert.assertTrue(client.getResponseBody().contains("<myvalue xmlns=\"http://tomcat.apache.org/testsuite\">"));
- client.setRequest(new String[] { "MOVE /file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Destination: /file3.txt" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "MOVE /file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Destination: /file3.txt" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "PROPFIND /file3.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + PROPFIND_PROP.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + PROPFIND_PROP });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND /file3.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + PROPFIND_PROP.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ PROPFIND_PROP
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
@@ -413,20 +458,32 @@ public class TestWebdavServlet extends TomcatBaseTest {
client.setPort(getPort());
// Create a few files
- client.setRequest(new String[] { "PUT /file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "PUT /file2.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 12" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT + CONTENT });
+ // @formatter:off
+
+ client.setRequest(new String[] {
+ "PUT /file2.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 12" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
@@ -435,48 +492,71 @@ public class TestWebdavServlet extends TomcatBaseTest {
for (int i = 0; i < 100; i++) {
sb.append(CONTENT);
}
- client.setRequest(new String[] { "PUT /file12.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + String.valueOf(sb.length()) + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + sb.toString() });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /file12.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + String.valueOf(sb.length()) + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ sb.toString()
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "MKCOL /myfolder HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "MKCOL /myfolder HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "PUT /myfolder/file3.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/file3.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
// Verify that listing the file works
- client.setRequest(new String[] { "PROPFIND / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("<D:getcontentlength>12<"));
// Lock /myfolder
- client.setRequest(new String[] { "LOCK /myfolder HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -490,61 +570,88 @@ public class TestWebdavServlet extends TomcatBaseTest {
Assert.assertNotNull(lockToken);
// Try to add /myfolder/file4.txt to myfolder without lock token
- client.setRequest(new String[] { "PUT /myfolder/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_LOCKED, client.getStatusCode());
// Same but provide the lock token
- client.setRequest(new String[] { "PUT /myfolder/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "If: </myfolder/> (" + lockToken + ")" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {"PUT /myfolder/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "If: </myfolder/> (" + lockToken + ")" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
// Add lock for /myfolder/file5.txt
- client.setRequest(new String[] { "LOCK /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_LOCKED, client.getStatusCode());
- client.setRequest(new String[] { "UNLOCK /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Lock-Token: <my:locktoken>" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "UNLOCK /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Lock-Token: <my:locktoken>" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CONFLICT, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("<D:href>/myfolder</D:href>"));
// Unlock /myfolder
- client.setRequest(new String[] { "UNLOCK /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Lock-Token: " + lockToken + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "UNLOCK /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Lock-Token: " + lockToken + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
- client.setRequest(new String[] { "LOCK /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
@@ -557,63 +664,93 @@ public class TestWebdavServlet extends TomcatBaseTest {
}
Assert.assertNotNull(lockTokenFile);
- client.setRequest(new String[] { "LOCK /myfolder HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("/myfolder/file5.txt"));
Assert.assertTrue(client.getResponseBody().contains("HTTP/1.1 423"));
- client.setRequest(new String[] { "PUT /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+
+ client.setRequest(new String[] {
+ "PUT /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_LOCKED, client.getStatusCode());
// Same but with lock token and lock null
- client.setRequest(new String[] { "PUT /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "If: (" + lockTokenFile + ")" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "If: (" + lockTokenFile + ")" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
// Verify that this also removes the lock by doing another PUT without the token
- client.setRequest(new String[] { "DELETE /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "If: (" + lockTokenFile + ")" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "DELETE /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "If: (" + lockTokenFile + ")" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
- client.setRequest(new String[] { "PUT /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
// Lock /myfolder again
- client.setRequest(new String[] { "LOCK /myfolder HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Timeout: Second-20" + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Timeout: Second-20" + CRLF +
+ "Content-Length: " + LOCK_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -627,40 +764,57 @@ public class TestWebdavServlet extends TomcatBaseTest {
Assert.assertNotNull(lockToken);
// Copy /myfolder/file5.txt to /myfolder/file6.txt without lock (should not work)
- client.setRequest(new String[] { "COPY /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Destination: http://localhost:" + getPort() + "/myfolder/file6.txt" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "COPY /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Destination: http://localhost:" + getPort() + "/myfolder/file6.txt" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_LOCKED, client.getStatusCode());
- client.setRequest(new String[] { "COPY /myfolder HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Destination: /myfolder2" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+
+ client.setRequest(new String[] {
+ "COPY /myfolder HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Destination: /myfolder2" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_CREATED, client.getStatusCode());
// Delete /myfolder/file4.txt
- client.setRequest(new String[] { "DELETE /myfolder/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "If: (" + lockToken + ")" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "DELETE /myfolder/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "If: (" + lockToken + ")" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
// Copy /myfolder/file5.txt to /file7.txt without lock (should work)
- client.setRequest(new String[] { "COPY /myfolder/file5.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Destination: http://localhost:" + getPort() + "/file7.txt" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "COPY /myfolder/file5.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Destination: http://localhost:" + getPort() + "/file7.txt" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
@@ -669,20 +823,29 @@ public class TestWebdavServlet extends TomcatBaseTest {
for (int i = 0; i < 3000; i++) {
sb2.append(CONTENT);
}
- client.setRequest(new String[] { "PUT /file6.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + String.valueOf(sb2.length()) + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + sb2.toString() });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /file6.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + String.valueOf(sb2.length()) + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ sb2.toString()
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
// Verify that everything created is there
- client.setRequest(new String[] { "PROPFIND / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
@@ -696,36 +859,51 @@ public class TestWebdavServlet extends TomcatBaseTest {
Assert.assertTrue(Integer.valueOf(timeoutValue).intValue() <= 20);
// Unlock /myfolder again
- client.setRequest(new String[] { "UNLOCK /myfolder/ HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Lock-Token: " + lockToken + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "UNLOCK /myfolder/ HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Lock-Token: " + lockToken + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
// Delete /myfolder
- client.setRequest(new String[] { "DELETE /myfolder HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "DELETE /myfolder HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
- client.setRequest(new String[] { "DELETE /myfolder2 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "DELETE /myfolder2 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
- client.setRequest(new String[] { "PROPFIND / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] { "PROPFIND / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
@@ -758,51 +936,72 @@ public class TestWebdavServlet extends TomcatBaseTest {
client.setPort(getPort());
// Create a file
- client.setRequest(new String[] { "PUT /aaa/file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /aaa/file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
// Copy file1.txt to file2.txt
- client.setRequest(new String[] { "COPY /aaa/file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Destination: http://localhost:" + getPort() + "/aaa/file2.txt" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "COPY /aaa/file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Destination: http://localhost:" + getPort() + "/aaa/file2.txt" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
// Move file2.txt to file3.txt
- client.setRequest(new String[] { "MOVE /aaa/file2.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Destination: http://localhost:" + getPort() + "/aaa/file3.txt" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "MOVE /aaa/file2.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Destination: http://localhost:" + getPort() + "/aaa/file3.txt" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
// Copy file1.txt outside sub-path
- client.setRequest(new String[] { "COPY /aaa/file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Destination: http://localhost:" + getPort() + "/file1.txt" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "COPY /aaa/file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Destination: http://localhost:" + getPort() + "/file1.txt" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_FORBIDDEN, client.getStatusCode());
// Move file1.txt outside sub-path
- client.setRequest(new String[] { "MOVE /aaa/file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Destination: http://localhost:" + getPort() + "/file1.txt" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "MOVE /aaa/file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Destination: http://localhost:" + getPort() + "/file1.txt" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_FORBIDDEN, client.getStatusCode());
@@ -828,79 +1027,122 @@ public class TestWebdavServlet extends TomcatBaseTest {
client.setPort(getPort());
// Create a few folders and files
- client.setRequest(new String[] { "MKCOL /myfolder HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "MKCOL /myfolder HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "MKCOL /myfolder/myfolder2/ HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+
+ client.setRequest(new String[] {
+ "MKCOL /myfolder/myfolder2/ HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "MKCOL /myfolder/myfolder3 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "MKCOL /myfolder/myfolder3 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "MKCOL /myfolder/myfolder2/myfolder4 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "MKCOL /myfolder/myfolder2/myfolder4 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "MKCOL /myfolder/myfolder2/myfolder4/myfolder5 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "MKCOL /myfolder/myfolder2/myfolder4/myfolder5 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "PUT /file1.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+
+ client.setRequest(new String[] {
+ "PUT /file1.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "PUT /myfolder/myfolder3/file2.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+
+ client.setRequest(new String[] {
+ "PUT /myfolder/myfolder3/file2.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "PUT /myfolder/myfolder2/myfolder4/file3.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/myfolder2/myfolder4/file3.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
// Lock /myfolder
- client.setRequest(new String[] { "LOCK /myfolder HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_SHARED_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_SHARED_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_SHARED_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_SHARED_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -913,33 +1155,47 @@ public class TestWebdavServlet extends TomcatBaseTest {
}
Assert.assertNotNull(lockToken);
- client.setRequest(new String[] { "LOCK /myfolder/myfolder2/myfolder4/myfolder5 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "If: (" + lockToken + ")" + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder/myfolder2/myfolder4/myfolder5 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "If: (" + lockToken + ")" + CRLF +
+ "Content-Length: " + LOCK_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
// This should conflict, submitting a token does not help
Assert.assertEquals(WebdavStatus.SC_LOCKED, client.getStatusCode());
// Lock refresh /myfolder
- client.setRequest(new String[] { "LOCK /myfolder HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Timeout: Infinite" + SimpleHttpClient.CRLF +
- "If: (" + lockToken + ")" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Timeout: Infinite" + CRLF +
+ "If: (" + lockToken + ")" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
- client.setRequest(new String[] { "LOCK /myfolder/myfolder2/myfolder4 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_SHARED_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_SHARED_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder/myfolder2/myfolder4 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_SHARED_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_SHARED_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -953,11 +1209,16 @@ public class TestWebdavServlet extends TomcatBaseTest {
Assert.assertNotNull(lockToken2);
// Take a second different lock on the same collection
- client.setRequest(new String[] { "LOCK /myfolder/myfolder2/myfolder4 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_SHARED_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_SHARED_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder/myfolder2/myfolder4 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_SHARED_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_SHARED_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -971,10 +1232,14 @@ public class TestWebdavServlet extends TomcatBaseTest {
Assert.assertNotNull(lockToken3);
validateXml(client.getResponseBody());
- client.setRequest(new String[] { "PROPFIND / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
@@ -985,101 +1250,149 @@ public class TestWebdavServlet extends TomcatBaseTest {
Assert.assertTrue(Integer.valueOf(timeoutValue).intValue() > 100000);
validateXml(client.getResponseBody());
- client.setRequest(new String[] { "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_LOCKED, client.getStatusCode());
- client.setRequest(new String[] { "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "If: (" + lockToken + ")" + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "If: (" + lockToken + ")" + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_PRECONDITION_FAILED, client.getStatusCode());
- client.setRequest(new String[] { "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "If: </myfolder/myfolder2/myfolder4/myfolder5> (" + lockToken + ")" + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "If: </myfolder/myfolder2/myfolder4/myfolder5> (" + lockToken + ")" + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CREATED, client.getStatusCode());
- client.setRequest(new String[] { "UNLOCK /myfolder/myfolder3 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Lock-Token: " + lockToken2 + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "UNLOCK /myfolder/myfolder3 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Lock-Token: " + lockToken2 + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_CONFLICT, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains("<D:lock-token-matches-request-uri/>"));
- client.setRequest(new String[] { "UNLOCK /myfolder/myfolder2/myfolder4/myfolder5 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Lock-Token: " + lockToken2 + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "UNLOCK /myfolder/myfolder2/myfolder4/myfolder5 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Lock-Token: " + lockToken2 + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
- client.setRequest(new String[] { "UNLOCK /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Lock-Token: " + lockToken3 + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "UNLOCK /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Lock-Token: " + lockToken3 + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
- client.setRequest(new String[] { "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ // @formatter:off
+
+ client.setRequest(new String[] {
+ "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_LOCKED, client.getStatusCode());
- client.setRequest(new String[] { "UNLOCK /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Lock-Token: " + lockToken + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+
+ client.setRequest(new String[] {
+ "UNLOCK /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Lock-Token: " + lockToken + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_NO_CONTENT, client.getStatusCode());
- client.setRequest(new String[] { "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: 12" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT + CONTENT});
+ // @formatter:off
+
+ client.setRequest(new String[] {
+ "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 12" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_NO_CONTENT, client.getStatusCode());
- client.setRequest(new String[] { "PROPFIND / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
// Verify all the shared locks are cleared
Assert.assertFalse(client.getResponseBody().contains("urn:uuid:"));
validateXml(client.getResponseBody());
-
}
@Test
@@ -1109,11 +1422,16 @@ public class TestWebdavServlet extends TomcatBaseTest {
Client client = new Client();
client.setPort(getPort());
- client.setRequest(new String[] { "LOCK /myfolder/myfolder3 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder/myfolder3 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -1126,11 +1444,16 @@ public class TestWebdavServlet extends TomcatBaseTest {
}
Assert.assertNotNull(lockToken);
- client.setRequest(new String[] { "LOCK /myfolder/myfolder7 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_SHARED_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_SHARED_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder/myfolder7 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_SHARED_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_SHARED_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -1143,11 +1466,16 @@ public class TestWebdavServlet extends TomcatBaseTest {
}
Assert.assertNotNull(lockToken2);
- client.setRequest(new String[] { "LOCK /myfolder/myfolder7/myfolder8 HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Content-Length: " + LOCK_SHARED_BODY.length() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + LOCK_SHARED_BODY });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "LOCK /myfolder/myfolder7/myfolder8 HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: " + LOCK_SHARED_BODY.length() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ LOCK_SHARED_BODY
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(HttpServletResponse.SC_OK, client.getStatusCode());
@@ -1160,32 +1488,41 @@ public class TestWebdavServlet extends TomcatBaseTest {
}
Assert.assertNotNull(lockToken3);
- client.setRequest(new String[] { "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
"If: </myfolder/myfolder3/myfolder6> (<urn:uuid:5e1e2275b1cd9c17845e7e08>)" + // Obvious wrong token
" </myfolder/myfolder7/myfolder8/myfolder9> (" + lockToken + " " + lockToken2 + " " + lockToken3 + ")" + // lockToken is not there
" </myfolder/myfolder2/myfolder4> (<urn:uuid:7329872398754923752> [W/\"4-1729375899470\"])" + // Not locked
- " </myfolder/myfolder7/myfolder8> (" + lockToken + ")" + SimpleHttpClient.CRLF + // lockToken is not there
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ " </myfolder/myfolder7/myfolder8> (" + lockToken + ")" + CRLF + // lockToken is not there
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_PRECONDITION_FAILED, client.getStatusCode());
- client.setRequest(new String[] { "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PUT /myfolder/myfolder2/myfolder4/myfolder5/file4.txt HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
"If: </myfolder/myfolder3/myfolder6> (<urn:uuid:5e1e2275b1cd9c17845e7e08>)" + // Obvious wrong token
" </myfolder/myfolder2/myfolder4> (<urn:uuid:7329872398754923752> [W/\"4-1729375899470\"])" + // Not locked
" </myfolder/myfolder7/myfolder8> (" + lockToken + ")" + // lockToken is not there
- " </myfolder/myfolder7/myfolder8/myfolder9> (" + lockToken2 + " " + lockToken3 + ")" + SimpleHttpClient.CRLF + // Correct
- "Content-Length: 6" + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + CONTENT });
+ " </myfolder/myfolder7/myfolder8/myfolder9> (" + lockToken2 + " " + lockToken3 + ")" + CRLF + // Correct
+ "Content-Length: 6" + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF +
+ CONTENT
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_CREATED, client.getStatusCode());
-
}
@Test
@@ -1210,16 +1547,19 @@ public class TestWebdavServlet extends TomcatBaseTest {
Client client = new Client();
client.setPort(getPort());
- client.setRequest(new String[] { "PROPFIND / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- "Connection: Close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF });
+ // @formatter:off
+ client.setRequest(new String[] {
+ "PROPFIND / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: Close" + CRLF +
+ CRLF
+ });
+ // @formatter:on
client.connect();
client.processRequest(true);
Assert.assertEquals(WebdavStatus.SC_MULTI_STATUS, client.getStatusCode());
Assert.assertTrue(client.getResponseBody().contains(">testvalue</mytestproperty>"));
validateXml(client.getResponseBody());
-
}
public static class CustomPropertyStore implements PropertyStore {
diff --git a/test/org/apache/catalina/valves/TestParameterLimitValve.java b/test/org/apache/catalina/valves/TestParameterLimitValve.java
index 3d7c2f799a..ffb1d7c425 100644
--- a/test/org/apache/catalina/valves/TestParameterLimitValve.java
+++ b/test/org/apache/catalina/valves/TestParameterLimitValve.java
@@ -76,17 +76,31 @@ public class TestParameterLimitValve extends TomcatBaseTest {
null);
Assert.assertEquals(200, rc);
- byte[] body = ("POST / HTTP/1.1" + CRLF + "Host: localhost:" + getPort() + CRLF + "Connection: close" + CRLF +
- "Transfer-Encoding: chunked" + CRLF + "Content-Type: application/x-www-form-urlencoded" + CRLF + CRLF +
+ // @formatter:off
+ byte[] body = (
+ "POST / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: close" + CRLF +
+ "Transfer-Encoding: chunked" + CRLF +
+ "Content-Type: application/x-www-form-urlencoded" + CRLF +
+ CRLF +
"param1=value1¶m2=value2¶m3=value3" + CRLF).getBytes(StandardCharsets.UTF_8);
+ // @formatter:on
rc = postUrl(body, "http://localhost:" + getPort() + "/special/endpoint", new ByteChunk(), null);
Assert.assertEquals(400, rc);
- body = ("POST / HTTP/1.1" + CRLF + "Host: localhost:" + getPort() + CRLF + "Connection: close" + CRLF +
- "Transfer-Encoding: chunked" + CRLF + "Content-Type: application/x-www-form-urlencoded" + CRLF + CRLF +
+ // @formatter:off
+ body = (
+ "POST / HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Connection: close" + CRLF +
+ "Transfer-Encoding: chunked" + CRLF +
+ "Content-Type: application/x-www-form-urlencoded" + CRLF +
+ CRLF +
"param1=value1¶m2=value2" + CRLF).getBytes(StandardCharsets.UTF_8);
+ // @formatter:on
rc = postUrl(body, "http://localhost:" + getPort() + "/special/endpoint", new ByteChunk(), null);
@@ -487,12 +501,17 @@ public class TestParameterLimitValve extends TomcatBaseTest {
// Construct a simple multipart body with two parts
String boundary = "--simpleBoundary";
+ // @formatter:off
String content = "--" + boundary + CRLF +
- "Content-Disposition: form-data; name=\"part1\"" + CRLF + CRLF +
+ "Content-Disposition: form-data; name=\"part1\"" + CRLF +
+ CRLF +
"part value 1" + CRLF +
"--" + boundary + CRLF +
- "Content-Disposition: form-data; name=\"part2\"" + CRLF + CRLF +
- "part value 2" + CRLF + "--" + boundary + "--" + CRLF;
+ "Content-Disposition: form-data; name=\"part2\"" + CRLF +
+ CRLF +
+ "part value 2" + CRLF +
+ "--" + boundary + "--" + CRLF;
+ // @formatter:on
Map<String,List<String>> reqHeaders = new HashMap<>();
reqHeaders.put("Content-Type", List.of("multipart/form-data; boundary=" + boundary));
diff --git a/test/org/apache/coyote/TestIoTimeouts.java b/test/org/apache/coyote/TestIoTimeouts.java
index c9b17860f7..243f75dc9f 100644
--- a/test/org/apache/coyote/TestIoTimeouts.java
+++ b/test/org/apache/coyote/TestIoTimeouts.java
@@ -108,12 +108,13 @@ public class TestIoTimeouts extends TomcatBaseTest {
}
String[] request = new String[packetCount];
+ // @formatter:off
request[0] =
- "POST /test HTTP/1.1" + CRLF +
- "Host: localhost:8080" + CRLF +
- "Transfer-Encoding: chunked" + CRLF +
- "Connection: close" + CRLF +
- CRLF;
+ "POST /test HTTP/1.1" + CRLF +
+ "Host: localhost:8080" + CRLF +
+ "Transfer-Encoding: chunked" + CRLF +
+ "Connection: close" + CRLF +
+ CRLF;
request[1] =
"b8" + CRLF +
"{" + CRLF +
@@ -124,6 +125,7 @@ public class TestIoTimeouts extends TomcatBaseTest {
" \"assetStoreId\": \"5051\", " + CRLF +
" \"zipCode\": \"98109\"" + CRLF +
"}" + CRLF;
+ // @formatter:on
if (sendEndChunk) {
request[2] =
"0" + CRLF +
diff --git a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
index 2a01bdd2cc..f0e86e7261 100644
--- a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
+++ b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
@@ -76,8 +76,15 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
connect();
String[] request = new String[1];
- request[0] = "GET http://localhost:8080/test HTTP/1.1" + CRLF + "Host: localhost:8080" + CRLF +
- "X-Bug48839: abcd" + CRLF + "\tefgh" + CRLF + "Connection: close" + CRLF + CRLF;
+ // @formatter:off
+ request[0] =
+ "GET http://localhost:8080/test HTTP/1.1" + CRLF +
+ "Host: localhost:8080" + CRLF +
+ "X-Bug48839: abcd" + CRLF +
+ "\tefgh" + CRLF +
+ "Connection: close" + CRLF +
+ CRLF;
+ // @formatter:on
setRequest(request);
processRequest(); // blocks until response has been read
@@ -322,8 +329,15 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
connect();
String[] request = new String[1];
- request[0] = "GET http://localhost:8080/test HTTP/1.1" + CRLF + "Host: localhost:8080" + CRLF +
- headerLine + CRLF + "X-Bug51557: abcd" + CRLF + "Connection: close" + CRLF + CRLF;
+ // @formatter:off
+ request[0] =
+ "GET http://localhost:8080/test HTTP/1.1" + CRLF +
+ "Host: localhost:8080" + CRLF +
+ headerLine + CRLF +
+ "X-Bug51557: abcd" + CRLF +
+ "Connection: close" + CRLF +
+ CRLF;
+ // @formatter:on
setRequest(request);
processRequest(); // blocks until response has been read
@@ -447,8 +461,16 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
connect();
String[] request = new String[1];
- request[0] = newLines + "GET http://localhost:8080/test HTTP/1.1" + CRLF + "Host: localhost:8080" +
- CRLF + "X-Bug48839: abcd" + CRLF + "\tefgh" + CRLF + "Connection: close" + CRLF + CRLF;
+ // @formatter:off
+ request[0] =
+ newLines +
+ "GET http://localhost:8080/test HTTP/1.1" + CRLF +
+ "Host: localhost:8080" + CRLF +
+ "X-Bug48839: abcd" + CRLF +
+ "\tefgh" + CRLF +
+ "Connection: close" + CRLF +
+ CRLF;
+ // @formatter:on
setRequest(request);
processRequest(); // blocks until response has been read
@@ -764,8 +786,14 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
tomcat.start();
- String request = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: localhost" + SimpleHttpClient.CRLF + ":b" +
- SimpleHttpClient.CRLF + "X-Dummy:b" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF +
+ "Host: localhost" + SimpleHttpClient.CRLF +
+ ":b" + SimpleHttpClient.CRLF +
+ "X-Dummy:b" + SimpleHttpClient.CRLF +
+ SimpleHttpClient.CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java b/test/org/apache/coyote/http11/TestHttp11Processor.java
index 863b20bf91..a8faab3f5b 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -50,6 +50,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.Connector;
@@ -83,8 +84,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /anything HTTP/1.1" + SimpleHttpClient.CRLF + "Host: any" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /anything HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -106,7 +111,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
// There should not be an end chunk
Assert.assertFalse(client.getResponseBody().endsWith("0"));
// The last portion of text should be there
- Assert.assertTrue(client.getResponseBody().endsWith("line03" + SimpleHttpClient.CRLF));
+ Assert.assertTrue(client.getResponseBody().endsWith("line03" + CRLF));
}
private static class ResponseWithErrorServlet extends HttpServlet {
@@ -148,8 +153,13 @@ public class TestHttp11Processor extends TomcatBaseTest {
public void testWithUnknownExpectation() throws Exception {
getTomcatInstanceTestWebapp(false, true);
- String request = "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF + "Host: any" +
- SimpleHttpClient.CRLF + "Expect: unknown" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Expect: unknown" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(getPort());
client.setRequest(new String[] { request });
@@ -164,10 +174,16 @@ public class TestHttp11Processor extends TomcatBaseTest {
public void testWithTEVoid() throws Exception {
getTomcatInstanceTestWebapp(false, true);
- String request = "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF + "Host: any" +
- SimpleHttpClient.CRLF + "Transfer-encoding: void" + SimpleHttpClient.CRLF + "Content-Length: 9" +
- SimpleHttpClient.CRLF + SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- SimpleHttpClient.CRLF + "test=data";
+ // @formatter:off
+ String request =
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: void" + CRLF +
+ "Content-Length: 9" + CRLF +
+ SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
+ CRLF +
+ "test=data";
+ // @formatter:on
Client client = new Client(getPort());
client.setRequest(new String[] { request });
@@ -182,10 +198,16 @@ public class TestHttp11Processor extends TomcatBaseTest {
public void testWithTEBuffered() throws Exception {
getTomcatInstanceTestWebapp(false, true);
- String request = "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF + "Host: any" +
- SimpleHttpClient.CRLF + "Transfer-encoding: buffered" + SimpleHttpClient.CRLF + "Content-Length: 9" +
- SimpleHttpClient.CRLF + SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- SimpleHttpClient.CRLF + "test=data";
+ // @formatter:off
+ String request =
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: buffered" + CRLF +
+ "Content-Length: 9" + CRLF +
+ SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
+ CRLF +
+ "test=data";
+ // @formatter:on
Client client = new Client(getPort());
client.setRequest(new String[] { request });
@@ -213,12 +235,20 @@ public class TestHttp11Processor extends TomcatBaseTest {
getTomcatInstanceTestWebapp(false, true);
- String request = "POST /test/echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF + "Host: any" +
- SimpleHttpClient.CRLF + (withCL ? "Content-length: 1" + SimpleHttpClient.CRLF : "") +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
- SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING + "Connection: close" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF + "9" + SimpleHttpClient.CRLF + "test=data" +
- SimpleHttpClient.CRLF + "0" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "POST /test/echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ (withCL ? "Content-length: 1" + CRLF : "") +
+ "Transfer-encoding: chunked" + CRLF +
+ SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
+ "Connection: close" + CRLF +
+ CRLF +
+ "9" + CRLF +
+ "test=data" + CRLF +
+ "0" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(getPort());
client.setRequest(new String[] { request });
@@ -234,10 +264,16 @@ public class TestHttp11Processor extends TomcatBaseTest {
public void testWithTESavedRequest() throws Exception {
getTomcatInstanceTestWebapp(false, true);
- String request = "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF + "Host: any" +
- SimpleHttpClient.CRLF + "Transfer-encoding: savedrequest" + SimpleHttpClient.CRLF +
- "Content-Length: 9" + SimpleHttpClient.CRLF +
- SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING + SimpleHttpClient.CRLF + "test=data";
+ // @formatter:off
+ String request =
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: savedrequest" + CRLF +
+ "Content-Length: 9" + CRLF +
+ SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
+ CRLF +
+ "test=data";
+ // @formatter:on
Client client = new Client(getPort());
client.setRequest(new String[] { request });
@@ -252,10 +288,16 @@ public class TestHttp11Processor extends TomcatBaseTest {
public void testWithTEUnsupported() throws Exception {
getTomcatInstanceTestWebapp(false, true);
- String request = "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF + "Host: any" +
- SimpleHttpClient.CRLF + "Transfer-encoding: unsupported" + SimpleHttpClient.CRLF + "Content-Length: 9" +
- SimpleHttpClient.CRLF + SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- SimpleHttpClient.CRLF + "test=data";
+ // @formatter:off
+ String request =
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: unsupported" + CRLF +
+ "Content-Length: 9" + CRLF +
+ SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
+ CRLF +
+ "test=data";
+ // @formatter:on
Client client = new Client(getPort());
client.setRequest(new String[] { request });
@@ -279,8 +321,8 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String requestPart1 = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF;
- String requestPart2 = "Host: any" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ String requestPart1 = "GET /foo HTTP/1.1" + CRLF;
+ String requestPart2 = "Host: any" + CRLF + CRLF;
final Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { requestPart1, requestPart2 });
@@ -335,9 +377,15 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: any" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF + "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: any" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /foo HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ CRLF +
+ "GET /foo HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ CRLF;
+ // @formatter:on
final Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -534,12 +582,15 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "POST /echo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: localhost:" + getPort() +
- SimpleHttpClient.CRLF + "Content-Length: 10" + SimpleHttpClient.CRLF;
- if (useExpectation) {
- request += "Expect: 100-continue" + SimpleHttpClient.CRLF;
- }
- request += SimpleHttpClient.CRLF + "HelloWorld";
+ // @formatter:off
+ String request =
+ "POST /echo HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 10" + CRLF +
+ (useExpectation ? "Expect: 100-continue" + CRLF : "") +
+ CRLF +
+ "HelloWorld";
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -985,8 +1036,13 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: a" + SimpleHttpClient.CRLF + "Host: b" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /foo HTTP/1.1" + CRLF +
+ "Host: a" + CRLF +
+ "Host: b" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1018,8 +1074,13 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: a" + SimpleHttpClient.CRLF + "Host: a" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /foo HTTP/1.1" + CRLF +
+ "Host: a" + CRLF +
+ "Host: a" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1048,7 +1109,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ String request = "GET /foo HTTP/1.1" + CRLF + CRLF;
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1077,8 +1138,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://a/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: b" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://a/foo HTTP/1.1" + CRLF +
+ "Host: b" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1107,8 +1172,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://a:8080/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: b:8080" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://a:8080/foo HTTP/1.1" + CRLF +
+ "Host: b:8080" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1137,8 +1206,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://user:pwd@a/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: b" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://user:pwd@a/foo HTTP/1.1" + CRLF +
+ "Host: b" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1170,8 +1243,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://a/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: " + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://a/foo HTTP/1.1" + CRLF +
+ "Host: " + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1203,8 +1280,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://a:8080/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: " + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://a:8080/foo HTTP/1.1" + CRLF +
+ "Host: " + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1236,8 +1317,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://user:pwd@a/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: " +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://user:pwd@a/foo HTTP/1.1" + CRLF +
+ "Host: " + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1270,8 +1355,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://a/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: a" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://a/foo HTTP/1.1" + CRLF +
+ "Host: a" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1305,8 +1394,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://a:8080/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: a:8080" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://a:8080/foo HTTP/1.1" + CRLF +
+ "Host: a:8080" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1341,8 +1434,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://user:pwd@a/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: a" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://user:pwd@a/foo HTTP/1.1" + CRLF +
+ "Host: a" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1376,8 +1473,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET http://a/foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: A" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET http://a/foo HTTP/1.1" + CRLF +
+ "Host: A" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1412,8 +1513,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: " + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /foo HTTP/1.1" + CRLF +
+ "Host: " + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1448,8 +1553,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: " + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /foo HTTP/1.1" + CRLF +
+ "Host: " + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1540,14 +1649,13 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: localhost:" + getPort() +
- SimpleHttpClient.CRLF;
-
- if (sendKeepAlive) {
- request += "Connection: keep-alive" + SimpleHttpClient.CRLF;
- }
-
- request += SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /foo HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ (sendKeepAlive ? "Connection: keep-alive" + CRLF : "") +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1657,8 +1765,13 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "POST /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: localhost:" + getPort() +
- SimpleHttpClient.CRLF + "Content-Length: 10" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "POST /foo HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Content-Length: 10" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request, "XXXXXXXXXX" });
@@ -1812,9 +1925,13 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: localhost:" + getPort() +
- SimpleHttpClient.CRLF + "Transfer-Encoding: " + headerValue + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /foo HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Transfer-Encoding: " + headerValue + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1835,11 +1952,19 @@ public class TestHttp11Processor extends TomcatBaseTest {
getTomcatInstanceTestWebapp(false, true);
- String request = "POST /test/echo-params.jsp HTTP/1.0" + SimpleHttpClient.CRLF + "Host: any" +
- SimpleHttpClient.CRLF + "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
- SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING + "Connection: close" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF + "9" + SimpleHttpClient.CRLF + "test=data" +
- SimpleHttpClient.CRLF + "0" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "POST /test/echo-params.jsp HTTP/1.0" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
+ SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
+ "Connection: close" + CRLF +
+ CRLF +
+ "9" + CRLF +
+ "test=data" + CRLF +
+ "0" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(getPort());
client.setRequest(new String[] { request });
@@ -1867,9 +1992,15 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "POST /foo HTTP/1.1" + SimpleHttpClient.CRLF + "Host: localhost:" + getPort() +
- SimpleHttpClient.CRLF + "Expect: 100-continue" + SimpleHttpClient.CRLF + "Content-Length: 10" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF + "0123456789";
+ // @formatter:off
+ String request =
+ "POST /foo HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ "Expect: 100-continue" + CRLF +
+ "Content-Length: 10" + CRLF +
+ CRLF +
+ "0123456789";
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1886,7 +2017,6 @@ public class TestHttp11Processor extends TomcatBaseTest {
client.processRequest(false);
Assert.assertTrue(client.isResponse200());
-
}
@@ -1894,8 +2024,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
public void testConnect() throws Exception {
getTomcatInstanceTestWebapp(false, true);
- String request = "CONNECT example.local HTTP/1.1" + SimpleHttpClient.CRLF + "Host: example.local" +
- SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "CONNECT example.local HTTP/1.1" + CRLF +
+ "Host: example.local" + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(getPort());
client.setRequest(new String[] { request });
@@ -1930,9 +2064,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /ehs HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /ehs HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1959,9 +2096,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /ehs HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /ehs HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
@@ -1989,9 +2129,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- String request = "GET /ehs HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost:" + getPort() + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "GET /ehs HTTP/1.1" + CRLF +
+ "Host: localhost:" + getPort() + CRLF +
+ CRLF;
+ // @formatter:on
Client client = new Client(tomcat.getConnector().getLocalPort());
client.setRequest(new String[] { request });
diff --git a/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java b/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java
index 86071ad20d..d4f11b5b98 100644
--- a/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java
+++ b/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java
@@ -35,6 +35,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.junit.Assert;
import org.junit.Test;
+import static org.apache.catalina.startup.SimpleHttpClient.CRLF;
import org.apache.catalina.Context;
import org.apache.catalina.Wrapper;
import org.apache.catalina.startup.SimpleHttpClient;
@@ -116,23 +117,25 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
tomcat.start();
- String[] request = new String[]{
- "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: any" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
+ // @formatter:off
+ String[] request = new String[] {
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- "Connection: close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "3" + (chunkHeaderUsesCRLF ? SimpleHttpClient.CRLF : SimpleHttpClient.LF) +
- "a=0" + (chunkUsesCRLF ? SimpleHttpClient.CRLF : SimpleHttpClient.LF) +
- "4" + SimpleHttpClient.CRLF +
- "&b=1" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
+ "Connection: close" + CRLF +
+ CRLF +
+ "3" + (chunkHeaderUsesCRLF ? CRLF : SimpleHttpClient.LF) +
+ "a=0" + (chunkUsesCRLF ? CRLF : SimpleHttpClient.LF) +
+ "4" + CRLF +
+ "&b=1" + CRLF +
+ "0" + CRLF +
"x-trailer1: Test", "Value1" +
- (firstheaderUsesCRLF ? SimpleHttpClient.CRLF : SimpleHttpClient.LF) +
+ (firstheaderUsesCRLF ? CRLF : SimpleHttpClient.LF) +
"x-trailer2: TestValue2" +
- (secondheaderUsesCRLF ? SimpleHttpClient.CRLF : SimpleHttpClient.LF) +
- (endUsesCRLF ? SimpleHttpClient.CRLF : SimpleHttpClient.LF) };
+ (secondheaderUsesCRLF ? CRLF : SimpleHttpClient.LF) +
+ (endUsesCRLF ? CRLF : SimpleHttpClient.LF) };
+ // @formatter:on
TrailerClient client =
new TrailerClient(tomcat.getConnector().getLocalPort());
@@ -189,22 +192,24 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
*/
@Test
public void testTrailingHeadersSizeLimitPipelining() throws Exception {
+ // @formatter:off
doTestTrailingHeadersSizeLimit(19,
- "x-trailer: Test" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: any" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
+ "x-trailer: Test" + CRLF +
+ CRLF +
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- "Connection: close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "3" + SimpleHttpClient.CRLF +
- "a=0" + SimpleHttpClient.CRLF +
- "4" + SimpleHttpClient.CRLF +
- "&b=1" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
+ "Connection: close" + CRLF +
+ CRLF +
+ "3" + CRLF +
+ "a=0" + CRLF +
+ "4" + CRLF +
+ "&b=1" + CRLF +
+ "0" + CRLF +
"x-trailer: Test",
true);
+ // @formatter:on
}
@@ -225,20 +230,23 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
Assert.assertTrue(tomcat.getConnector().setProperty("maxTrailerSize", Integer.toString(trailerSizeLimit)));
tomcat.start();
- String[] request = new String[]{
- "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: any" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
+ // @formatter:off
+ String[] request = new String[] {
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- "Connection: close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "3" + SimpleHttpClient.CRLF +
- "a=0" + SimpleHttpClient.CRLF +
- "4" + SimpleHttpClient.CRLF +
- "&b=1" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- trailerHeader + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF };
+ "Connection: close" + CRLF +
+ CRLF +
+ "3" + CRLF +
+ "a=0" + CRLF +
+ "4" + CRLF +
+ "&b=1" + CRLF +
+ "0" + CRLF +
+ trailerHeader + CRLF +
+ CRLF
+ };
+ // @formatter:on
TrailerClient client =
new TrailerClient(tomcat.getConnector().getLocalPort());
@@ -293,19 +301,22 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
extValue.append('x');
}
- String[] request = new String[]{
- "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: any" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
+ // @formatter:off
+ String[] request = new String[] {
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- "Connection: close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "3" + extName + extValue.toString() + SimpleHttpClient.CRLF +
- "a=0" + SimpleHttpClient.CRLF +
- "4" + SimpleHttpClient.CRLF +
- "&b=1" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF };
+ "Connection: close" + CRLF +
+ CRLF +
+ "3" + extName + extValue.toString() + CRLF +
+ "a=0" + CRLF +
+ "4" + CRLF +
+ "&b=1" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
TrailerClient client =
new TrailerClient(tomcat.getConnector().getLocalPort());
@@ -334,19 +345,21 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
tomcat.start();
+ // @formatter:off
String request =
- "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: any" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- "Connection: close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "3" + SimpleHttpClient.CRLF +
- "a=0" + SimpleHttpClient.CRLF +
- "4" + SimpleHttpClient.CRLF +
- "&b=1" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF;
+ "Connection: close" + CRLF +
+ CRLF +
+ "3" + CRLF +
+ "a=0" + CRLF +
+ "4" + CRLF +
+ "&b=1" + CRLF +
+ "0" + CRLF +
+ CRLF;
+ // @formatter:on
TrailerClient client =
new TrailerClient(tomcat.getConnector().getLocalPort());
@@ -364,43 +377,43 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
@Test
public void testChunkSizeAbsent() throws Exception {
- doTestChunkSize(false, false, SimpleHttpClient.CRLF, 10, 0);
+ doTestChunkSize(false, false, CRLF, 10, 0);
}
@Test
public void testChunkSizeTwentyFive() throws Exception {
- doTestChunkSize(true, true, "19" + SimpleHttpClient.CRLF
- + "Hello World!Hello World!!" + SimpleHttpClient.CRLF, 40, 25);
+ doTestChunkSize(true, true, "19" + CRLF
+ + "Hello World!Hello World!!" + CRLF, 40, 25);
}
@Test
public void testChunkSizeEightDigit() throws Exception {
- doTestChunkSize(true, true, "0000000C" + SimpleHttpClient.CRLF
- + "Hello World!" + SimpleHttpClient.CRLF, 20, 12);
+ doTestChunkSize(true, true, "0000000C" + CRLF
+ + "Hello World!" + CRLF, 20, 12);
}
@Test
public void testChunkSizeNineDigit() throws Exception {
- doTestChunkSize(false, false, "00000000C" + SimpleHttpClient.CRLF
- + "Hello World!" + SimpleHttpClient.CRLF, 20, 12);
+ doTestChunkSize(false, false, "00000000C" + CRLF
+ + "Hello World!" + CRLF, 20, 12);
}
@Test
public void testChunkSizeLong() throws Exception {
- doTestChunkSize(true, false, "7fFFffFF" + SimpleHttpClient.CRLF
- + "Hello World!" + SimpleHttpClient.CRLF, 10, 10);
+ doTestChunkSize(true, false, "7fFFffFF" + CRLF
+ + "Hello World!" + CRLF, 10, 10);
}
@Test
public void testChunkSizeIntegerMinValue() throws Exception {
- doTestChunkSize(false, false, "80000000" + SimpleHttpClient.CRLF
- + "Hello World!" + SimpleHttpClient.CRLF, 10, 10);
+ doTestChunkSize(false, false, "80000000" + CRLF
+ + "Hello World!" + CRLF, 10, 10);
}
@Test
public void testChunkSizeMinusOne() throws Exception {
- doTestChunkSize(false, false, "ffffffff" + SimpleHttpClient.CRLF
- + "Hello World!" + SimpleHttpClient.CRLF, 10, 10);
+ doTestChunkSize(false, false, "ffffffff" + CRLF
+ + "Hello World!" + CRLF, 10, 10);
}
/**
@@ -433,15 +446,18 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
tomcat.start();
- String request = "POST /echo-params.jsp HTTP/1.1"
- + SimpleHttpClient.CRLF + "Host: any" + SimpleHttpClient.CRLF
- + "Transfer-encoding: chunked" + SimpleHttpClient.CRLF
- + "Content-Type: text/plain" + SimpleHttpClient.CRLF;
- if (expectPass) {
- request += "Connection: close" + SimpleHttpClient.CRLF;
- }
- request += SimpleHttpClient.CRLF + chunks + "0" + SimpleHttpClient.CRLF
- + SimpleHttpClient.CRLF;
+ // @formatter:off
+ String request =
+ "POST /echo-params.jsp HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
+ "Content-Type: text/plain" + CRLF +
+ (expectPass ? "Connection: close" + CRLF : "") +
+ CRLF +
+ chunks +
+ "0" + CRLF +
+ CRLF;
+ // @formatter:on
TrailerClient client = new TrailerClient(tomcat.getConnector().getLocalPort());
// Need to use the content length here as variations in Connector and
@@ -504,20 +520,23 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
tomcat.start();
- String[] request = new String[]{
- "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
+ // @formatter:off
+ String[] request = new String[] {
+ "POST / HTTP/1.1" + CRLF +
+ "Host: localhost" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- "Connection: close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "3" + SimpleHttpClient.CRLF +
- "a=0" + SimpleHttpClient.CRLF +
- "4" + SimpleHttpClient.CRLF +
- "&b=1" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- "x@trailer: Test" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF };
+ "Connection: close" + CRLF +
+ CRLF +
+ "3" + CRLF +
+ "a=0" + CRLF +
+ "4" + CRLF +
+ "&b=1" + CRLF +
+ "0" + CRLF +
+ "x@trailer: Test" + CRLF +
+ CRLF
+ };
+ // @formatter:on
TrailerClient client = new TrailerClient(tomcat.getConnector().getLocalPort());
client.setRequest(request);
@@ -689,12 +708,15 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
tomcat.start();
- String[] request = new String[]{
- "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "3" + SimpleHttpClient.CRLF };
+ // @formatter:off
+ String[] request = new String[] {
+ "POST / HTTP/1.1" + CRLF +
+ "Host: localhost" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
+ CRLF +
+ "3" + CRLF
+ };
+ // @formatter:on
TrailerClient client = new TrailerClient(tomcat.getConnector().getLocalPort());
client.setUseContentLength(true);
@@ -745,15 +767,18 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
tomcat.start();
- String[] request = new String[]{
- "GET / HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: localhost" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "20" + SimpleHttpClient.CRLF +
- "01234567890123456789012345678901" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF };
+ // @formatter:off
+ String[] request = new String[] {
+ "GET / HTTP/1.1" + CRLF +
+ "Host: localhost" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
+ CRLF +
+ "20" + CRLF +
+ "01234567890123456789012345678901" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
TrailerClient client = new TrailerClient(tomcat.getConnector().getLocalPort());
client.setUseContentLength(true);
@@ -906,27 +931,30 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
tomcat.getConnector().setProperty("connectionTimeout", "300000");
tomcat.start();
- String[] request = new String[]{
- "POST /test HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: any" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
+ // @formatter:off
+ String[] request = new String[] {
+ "POST /test HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- "Connection: close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "7" + SimpleHttpClient.CRLF +
- "DATA01\n", SimpleHttpClient.CRLF +
- "7", SimpleHttpClient.CRLF +
- "DATA02\n" + SimpleHttpClient.CRLF,
- "7" + SimpleHttpClient.CRLF +
+ "Connection: close" + CRLF +
+ CRLF +
+ "7" + CRLF +
+ "DATA01\n", CRLF +
+ "7", CRLF +
+ "DATA02\n" + CRLF,
+ "7" + CRLF +
// Split the CRLF between writes
"DATA03\n" + SimpleHttpClient.CR,
SimpleHttpClient.LF +
- "7" + SimpleHttpClient.CRLF +
- "DATA04\n", SimpleHttpClient.CRLF +
- "13" + SimpleHttpClient.CRLF,
- "DATA05DATA05DATA05\n" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "7" + CRLF +
+ "DATA04\n", CRLF +
+ "13" + CRLF,
+ "DATA05DATA05DATA05\n" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
ReadLineClient client = new ReadLineClient(tomcat.getConnector().getLocalPort());
client.setRequest(request);
@@ -957,27 +985,30 @@ public class TestChunkedInputFilter extends TomcatBaseTest {
tomcat.getConnector().setProperty("connectionTimeout", "300000");
tomcat.start();
- String[] request = new String[]{
- "POST /test HTTP/1.1" + SimpleHttpClient.CRLF +
- "Host: any" + SimpleHttpClient.CRLF +
- "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
+ // @formatter:off
+ String[] request = new String[] {
+ "POST /test HTTP/1.1" + CRLF +
+ "Host: any" + CRLF +
+ "Transfer-encoding: chunked" + CRLF +
SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING +
- "Connection: close" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF +
- "7" + SimpleHttpClient.CRLF +
- "DATA01\n", SimpleHttpClient.CRLF +
- "7", SimpleHttpClient.CRLF +
- "DATA02\n" + SimpleHttpClient.CRLF,
- "7" + SimpleHttpClient.CRLF +
+ "Connection: close" + CRLF +
+ CRLF +
+ "7" + CRLF +
+ "DATA01\n", CRLF +
+ "7", CRLF +
+ "DATA02\n" + CRLF,
+ "7" + CRLF +
// Split the CRLF between writes
"DATA03\n" + SimpleHttpClient.CR,
SimpleHttpClient.LF +
- "7" + SimpleHttpClient.CRLF +
- "DATA04\n", SimpleHttpClient.CRLF +
- "13" + SimpleHttpClient.CRLF,
- "DATA05DATA05DATA05\n" + SimpleHttpClient.CRLF +
- "0" + SimpleHttpClient.CRLF +
- SimpleHttpClient.CRLF};
+ "7" + CRLF +
+ "DATA04\n", CRLF +
+ "13" + CRLF,
+ "DATA05DATA05DATA05\n" + CRLF +
+ "0" + CRLF +
+ CRLF
+ };
+ // @formatter:on
ReadLineClient client = new ReadLineClient(tomcat.getConnector().getLocalPort());
client.setRequest(request);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org