Skip to content

Commit 99f1107

Browse files
committed
FELIX-6782 Allow adding custom headers to Jetty error pages
- Add assertions - Document new property
1 parent b48bd00 commit 99f1107

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

http/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ properties can be used (some legacy property names still exist but are not docum
414414
| `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. |
415415
| `org.apache.felix.http.jetty.requestSizeLimit` | Maximum size of the request body in bytes. Default is unlimited. Added in Jetty12 1.0.30. |
416416
| `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. |
417+
| `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. |
417418
| `org.apache.felix.http.mbeans` | If `true`, enables the MBean server functionality. The default is `false`. |
418419
| `org.apache.felix.http.jetty.sendServerHeader` | If `false`, the `Server` HTTP header is no longer included in responses. The default is `false`. |
419420
| `org.eclipse.jetty.servlet.SessionCookie` | Name of the cookie used to transport the Session ID. The default is `JSESSIONID`. |

http/jetty12/src/test/java/org/apache/felix/http/jetty/it/JettyUriComplianceModeDefaultIT.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.junit.Assert.assertEquals;
2020
import static org.junit.Assert.assertNotNull;
21+
import static org.junit.Assert.assertNull;
2122
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
2223
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
2324

@@ -102,12 +103,17 @@ public void testUriCompliance() throws Exception {
102103
assertEquals(200, response.getStatus());
103104
assertEquals("OK", response.getContentAsString());
104105

106+
// Validate custom headers in case of success page, should not be present
107+
assertNull(response.getHeaders().get("Strict-Transport-Security"));
108+
assertNull(response.getHeaders().get("X-Custom-Header"));
109+
110+
105111
// blocked with HTTP 400 by default
106112
// validate custom headers in case of error page
107-
ContentResponse responseAmbigousPath = httpClient.GET(destUriAmbigousPath);
108-
assertEquals(400, responseAmbigousPath.getStatus());
109-
assertEquals("max-age=31536000", responseAmbigousPath.getHeaders().get("Strict-Transport-Security"));
110-
assertEquals("123", responseAmbigousPath.getHeaders().get("X-Custom-Header"));
113+
ContentResponse responseAmbiguousPath = httpClient.GET(destUriAmbigousPath);
114+
assertEquals(400, responseAmbiguousPath.getStatus());
115+
assertEquals("max-age=31536000", responseAmbiguousPath.getHeaders().get("Strict-Transport-Security"));
116+
assertEquals("123", responseAmbiguousPath.getHeaders().get("X-Custom-Header"));
111117

112118
httpClient.close();
113119
}

0 commit comments

Comments
 (0)