Repository navigation
Description
Jetty version(s)
This started in Jetty 12.1.12. In version 12.1.11 this issue does not occur.
Jetty Environment
jetty-ee9-proxy, jetty-ee10-proxy, jetty-ee11-proxy
HTTP version
Any
Java version/vendor (use: java -version)
openjdk version "17.0.20" 2026-07-21
OpenJDK Runtime Environment Temurin-17.0.20+8 (build 17.0.20+8)
OpenJDK 64-Bit Server VM Temurin-17.0.20+8 (build 17.0.20+8, mixed mode, sharing)
OS type/version
Windows 11
Description
Jetty 12.1.12 deprecated the existing AbstractProxyServlet.filterServerResponseHeader method and created an overload that works not with strings but with HttpField. It calls the deprecated method and then calls field.withValue. If the filtered value is different, this doesn't replace the value but adds to it. It also doesn't handle null return values correctly. This behavior is very different from version 12.1.12. I see two better implementations. The first:
String existingValue = field.getValue();
String filteredValue = filterServerResponseHeader(clientRequest, serverResponse, field.getName(), existingValue);
if (filteredValue == null) {
return null;
}
if (existingValue.equals(filteredValue) {
return field;
}
return new HttpField(field.getHeader(), field.getName(), filteredValue);The second is the same except for the final line:
return field.withoutValue(existingValue).withValue(filteredValue);How to reproduce?
Create a subclass of AbstractProxyServlet. Override the deprecated filterServerResponseHeader method to return something different for the location header, and `null`` for the date header:
if ("Location".equalsIgnoreCase(headerName)) {
return "http://localhost/proxy";
}
if ("Date".equalsIgnoreCase(headerName)) {
return null;
}
return super.filterServerResponseHeader(clientRequest, serverResponse, headerName, headerValue);Proxy to a URL that returns Location and Date headers.
In version 12.1.11 the client should see only one Location header value and no Date header.
In version 12.1.12 the client will see two Location header values (the original and the filtered one), and two Date header values (the original one and "null").
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
rob-spoor commentedon Aug 5, 2026
A possible extra option: give
HttpFieldan extrawithSingleValue(String value)method that does this:Then
filterServerResponseHeadercan replace the last two returns with a singlereturn field.withSingleValue(filteredValue)call. Thenullcheck remains necessary though.Fixes jetty#15548 - Replace/drop filtered proxy response headers
[SPARK-59647][BUILD] Upgrade Jetty to 12.1.13