diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyServlet.java index 5b2fa5676e7..e37bd297064 100644 --- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyServlet.java +++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyServlet.java @@ -534,6 +534,10 @@ public class ProxyServlet extends HttpServlet protected void onResponseHeaders(HttpServletRequest request, HttpServletResponse response, Response proxyResponse) { + // Clear the response headers in case it comes with predefined ones. + for (String name : response.getHeaderNames()) + response.setHeader(name, null); + for (HttpField field : proxyResponse.getHeaders()) { String headerName = field.getName(); @@ -545,7 +549,7 @@ public class ProxyServlet extends HttpServlet if (newHeaderValue == null || newHeaderValue.trim().length() == 0) continue; - response.setHeader(headerName, newHeaderValue); + response.addHeader(headerName, newHeaderValue); } }