This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new c74197e034 Make the HEAD test more meaningful by writing actual content
c74197e034 is described below
commit c74197e03450702a7902f3b364c8547a7cfeee89
Author: remm <[email protected]>
AuthorDate: Mon Oct 7 09:19:10 2024 +0200
Make the HEAD test more meaningful by writing actual content
---
.../apache/coyote/http11/TestHttp11Processor.java | 26 ++++++++++++++++------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index d2fd86e85d..4d97532999 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -802,14 +802,25 @@ public class TestHttp11Processor extends TomcatBaseTest {
tomcat.start();
- ByteChunk responseBody = new ByteChunk();
- Map<String, List<String>> responseHeaders = new HashMap<>();
+ ByteChunk getBody = new ByteChunk();
+ Map<String, List<String>> getHeaders = new HashMap<>();
+ int getStatus = getUrl("http://localhost:" + getPort() + "/test",
getBody, getHeaders);
- int rc = headUrl("http://localhost:" + getPort() + "/test",
responseBody, responseHeaders);
+ ByteChunk headBody = new ByteChunk();
+ Map<String, List<String>> headHeaders = new HashMap<>();
+ int headStatus = getUrl("http://localhost:" + getPort() + "/test",
headBody, headHeaders);
- Assert.assertEquals(HttpServletResponse.SC_OK, rc);
- Assert.assertEquals(0, responseBody.getLength());
- Assert.assertFalse(responseHeaders.containsKey("Content-Length"));
+ Assert.assertEquals(HttpServletResponse.SC_OK, getStatus);
+ Assert.assertEquals(HttpServletResponse.SC_OK, headStatus);
+
+ Assert.assertEquals(2, getBody.getLength());
+ Assert.assertEquals(2, headBody.getLength());
+
+ if (getHeaders.containsKey("Content-Length")) {
+ Assert.assertEquals(getHeaders.get("Content-Length"),
headHeaders.get("Content-Length"));
+ } else {
+ Assert.assertFalse(headHeaders.containsKey("Content-Length"));
+ }
}
@@ -819,11 +830,12 @@ public class TestHttp11Processor extends TomcatBaseTest {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
- super.doGet(req, resp);
+ resp.getWriter().print("OK");
}
@Override
protected void doHead(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
+ resp.getWriter().print("OK");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]