This is an automated email from the ASF dual-hosted git repository.
remm 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 6bb7babff4 Tests the compatibility with rewrite from httpd for non
existent headers
6bb7babff4 is described below
commit 6bb7babff48448084c7ce9e9d464da3f7f9ceeb9
Author: Paul Lodge <[email protected]>
AuthorDate: Thu Sep 12 13:09:51 2024 +0200
Tests the compatibility with rewrite from httpd for non existent headers
---
.../catalina/valves/rewrite/TestRewriteValve.java | 31 ++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
index 464a960384..da4d1c1052 100644
--- a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
+++ b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -617,6 +618,23 @@ public class TestRewriteValve extends TomcatBaseTest {
"/c", null, "aAa");
}
+ @Test
+ public void testRewriteEmptyHeader() throws Exception {
+
+ // Disable the following of redirects for this test only
+ boolean originalValue = HttpURLConnection.getFollowRedirects();
+ HttpURLConnection.setFollowRedirects(false);
+ try {
+ Map<String, List<String>> resHead = new HashMap<>();
+ Map<String, List<String>> reqHead = new HashMap<>();
+ reqHead.put("\"\"", Arrays.asList(new String[]{"Test"}));
+ doTestRewriteEx("RewriteCond %{HTTP:} .+\nRewriteRule .* - [F]",
"",
+ null, null, null, false, resHead, reqHead);
+ } finally {
+ HttpURLConnection.setFollowRedirects(originalValue);
+ }
+ }
+
@Test
public void testHostRewrite() throws Exception {
@@ -740,6 +758,12 @@ public class TestRewriteValve extends TomcatBaseTest {
private void doTestRewrite(String config, String request, String
expectedURI, String expectedQueryString,
String expectedAttributeValue, boolean valveSkip) throws Exception
{
+ doTestRewriteEx(config, request, expectedURI, expectedQueryString,
+ expectedAttributeValue, valveSkip, null, null);
+ }
+
+ private void doTestRewriteEx(String config, String request, String
expectedURI, String expectedQueryString,
+ String expectedAttributeValue, boolean valveSkip, Map<String,
List<String>> resHead, Map<String, List<String>> reqHead ) throws Exception {
Tomcat tomcat = getTomcatInstance();
@@ -769,7 +793,10 @@ public class TestRewriteValve extends TomcatBaseTest {
tomcat.start();
ByteChunk res = new ByteChunk();
- int rc = getUrl("http://localhost:" + getPort() + request, res, null);
+ int rc = methodUrl("http://localhost:" + getPort() + request, res,
DEFAULT_CLIENT_TIMEOUT_MS,
+ reqHead,
+ resHead,
+ "GET", true);
res.setCharset(StandardCharsets.UTF_8);
if (expectedURI == null) {
@@ -855,7 +882,7 @@ public class TestRewriteValve extends TomcatBaseTest {
tomcat.start();
Map<String, List<String>> reqHead = new HashMap<>();
- reqHead.put("cookie", List.of("test=data"));
+ reqHead.put("cookie", Arrays.asList("test=data"));
ByteChunk res = new ByteChunk();
int rc = methodUrl("http://localhost:" + getPort() +
"/source/cookieTest", res, DEFAULT_CLIENT_TIMEOUT_MS,
reqHead, null, "GET", false);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]