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

paulrutter pushed a commit to branch 
feature/FELIX-6782-Allow-adding-custom-headers-to-Jetty-error-pages
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to 
refs/heads/feature/FELIX-6782-Allow-adding-custom-headers-to-Jetty-error-pages 
by this push:
     new 99f1107ccd FELIX-6782 Allow adding custom headers to Jetty error pages 
- Add assertions - Document new property
99f1107ccd is described below

commit 99f1107ccdfa9cde220dba2ea18db5431ba0113f
Author: Paul Rütter <[email protected]>
AuthorDate: Mon May 19 21:14:38 2025 +0200

    FELIX-6782 Allow adding custom headers to Jetty error pages
    - Add assertions
    - Document new property
---
 http/README.md                                             |  1 +
 .../http/jetty/it/JettyUriComplianceModeDefaultIT.java     | 14 ++++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/http/README.md b/http/README.md
index f7a7a3cf6e..d49e879a56 100644
--- a/http/README.md
+++ b/http/README.md
@@ -414,6 +414,7 @@ properties can be used (some legacy property names still 
exist but are not docum
 | `org.apache.felix.http.jetty.maxFormSize`                | The maximum size 
accepted for a form post, in bytes (ony applies to form parameters). Defaults 
to 200 KB.                                                                      
                                                                                
                                                                                
                                                                                
                 [...]
 | `org.apache.felix.http.jetty.requestSizeLimit`           | Maximum size of 
the request body in bytes. Default is unlimited. Added in Jetty12 1.0.30.       
                                                                                
                                                                                
                                                                                
                                                                                
                [...]
 | `org.apache.felix.http.jetty.responseSizeLimit`          | Maximum size of 
the response body in bytes. Default is unlimited. Default is unlimited. Added 
in Jetty12 1.0.30.                                                              
                                                                                
                                                                                
                                                                                
                  [...]
+| `org.apache.felix.http.jetty.errorPageCustomHeaders`     | Configures the 
custom headers to add to all error pages served by Jetty. Separate key-value 
pairs with `##`, e.g. `X-Custom-Header=Value##X-Custom-Header2=Value2`. Added 
in Jetty12 1.0.32.                                                              
                                                                                
                                                                                
                      [...]
 | `org.apache.felix.http.mbeans`                           | If `true`, 
enables the MBean server functionality. The default is `false`.                 
                                                                                
                                                                                
                                                                                
                                                                                
                     [...]
 | `org.apache.felix.http.jetty.sendServerHeader`           | If `false`, the 
`Server` HTTP header is no longer included in responses. The default is 
`false`.                                                                        
                                                                                
                                                                                
                                                                                
                        [...]
 | `org.eclipse.jetty.servlet.SessionCookie`                | Name of the 
cookie used to transport the Session ID. The default is `JSESSIONID`.           
                                                                                
                                                                                
                                                                                
                                                                                
                    [...]
diff --git 
a/http/jetty12/src/test/java/org/apache/felix/http/jetty/it/JettyUriComplianceModeDefaultIT.java
 
b/http/jetty12/src/test/java/org/apache/felix/http/jetty/it/JettyUriComplianceModeDefaultIT.java
index dd43f9efc9..3ad003242c 100644
--- 
a/http/jetty12/src/test/java/org/apache/felix/http/jetty/it/JettyUriComplianceModeDefaultIT.java
+++ 
b/http/jetty12/src/test/java/org/apache/felix/http/jetty/it/JettyUriComplianceModeDefaultIT.java
@@ -18,6 +18,7 @@ package org.apache.felix.http.jetty.it;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
 
@@ -102,12 +103,17 @@ public class JettyUriComplianceModeDefaultIT extends 
AbstractJettyTestSupport {
         assertEquals(200, response.getStatus());
         assertEquals("OK", response.getContentAsString());
 
+        // Validate custom headers in case of success page, should not be 
present
+        assertNull(response.getHeaders().get("Strict-Transport-Security"));
+        assertNull(response.getHeaders().get("X-Custom-Header"));
+
+
         // blocked with HTTP 400 by default
         // validate custom headers in case of error page
-        ContentResponse responseAmbigousPath = 
httpClient.GET(destUriAmbigousPath);
-        assertEquals(400, responseAmbigousPath.getStatus());
-        assertEquals("max-age=31536000", 
responseAmbigousPath.getHeaders().get("Strict-Transport-Security"));
-        assertEquals("123", 
responseAmbigousPath.getHeaders().get("X-Custom-Header"));
+        ContentResponse responseAmbiguousPath = 
httpClient.GET(destUriAmbigousPath);
+        assertEquals(400, responseAmbiguousPath.getStatus());
+        assertEquals("max-age=31536000", 
responseAmbiguousPath.getHeaders().get("Strict-Transport-Security"));
+        assertEquals("123", 
responseAmbiguousPath.getHeaders().get("X-Custom-Header"));
 
         httpClient.close();
     }

Reply via email to