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 f035e6a278 Tests the compatibility with rewrite from httpd for non existent headers f035e6a278 is described below commit f035e6a27867855e587a5b4e5226c285271c7057 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 | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java index bd2163ba45..3a08886229 100644 --- a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java +++ b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java @@ -618,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 { @@ -741,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(); @@ -770,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) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org