This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 904b6e79ed Tests the compatibility with rewrite from httpd for non 
existent headers
904b6e79ed is described below

commit 904b6e79ed21435dd9e8017d808f30683d9eeb3c
Author: Paul Lodge <plo...@redhat.com>
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: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to