diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DelegatedJettyClientUpgradeRequest.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DelegatedJettyClientUpgradeRequest.java index 0d5d67e62be..ced3b82e3f7 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DelegatedJettyClientUpgradeRequest.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DelegatedJettyClientUpgradeRequest.java @@ -41,10 +41,12 @@ public class DelegatedJettyClientUpgradeRequest implements UpgradeRequest { private final CoreClientUpgradeRequest delegate; + private final Map> headers; public DelegatedJettyClientUpgradeRequest(CoreClientUpgradeRequest delegate) { this.delegate = delegate; + this.headers = HttpFields.asMap(delegate.getHeaders()); } @Override @@ -79,7 +81,7 @@ public List getHeaders(String name) @Override public Map> getHeaders() { - return HttpFields.asMap(delegate.getHeaders()); + return headers; } @Override diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DelegatedJettyClientUpgradeResponse.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DelegatedJettyClientUpgradeResponse.java index 0e05930cc2f..a93c8af1a1f 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DelegatedJettyClientUpgradeResponse.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/internal/DelegatedJettyClientUpgradeResponse.java @@ -32,10 +32,12 @@ public class DelegatedJettyClientUpgradeResponse implements UpgradeResponse { private final Response delegate; + private final Map> headers; public DelegatedJettyClientUpgradeResponse(Response response) { this.delegate = response; + this.headers = HttpFields.asMap(delegate.getHeaders()); } @Override @@ -65,7 +67,7 @@ public List getHeaders(String name) @Override public Map> getHeaders() { - return HttpFields.asMap(delegate.getHeaders()); + return headers; } @Override diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeRequestDelegate.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeRequestDelegate.java index 921aea05a47..4cc743bf64e 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeRequestDelegate.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeRequestDelegate.java @@ -35,10 +35,12 @@ class UpgradeRequestDelegate implements UpgradeRequest { private final ServerUpgradeRequest request; + private final Map> headers; UpgradeRequestDelegate(ServerUpgradeRequest request) { this.request = request; + this.headers = HttpFields.asMap(request.getHeaders()); } @Override @@ -72,7 +74,7 @@ public int getHeaderInt(String name) @Override public Map> getHeaders() { - return HttpFields.asMap(request.getHeaders()); + return headers; } @Override diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeResponseDelegate.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeResponseDelegate.java index 46b70485164..9340be8a6b3 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeResponseDelegate.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/UpgradeResponseDelegate.java @@ -27,10 +27,12 @@ class UpgradeResponseDelegate implements UpgradeResponse { private final ServerUpgradeResponse response; + private final Map> headers; UpgradeResponseDelegate(ServerUpgradeResponse response) { this.response = response; + this.headers = HttpFields.asMap(response.getHeaders()); } @Override @@ -62,7 +64,7 @@ public Set getHeaderNames() @Override public Map> getHeaders() { - return HttpFields.asMap(response.getHeaders()); + return headers; } @Override diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-server/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/server/internal/JsrHandshakeRequest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-server/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/server/internal/JsrHandshakeRequest.java index 546794d54f5..6bb10533fd2 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-server/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/server/internal/JsrHandshakeRequest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-server/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/server/internal/JsrHandshakeRequest.java @@ -33,6 +33,7 @@ public class JsrHandshakeRequest implements HandshakeRequest { private final ServerUpgradeRequest delegate; private final HttpServletRequest httpServletRequest; + private final Map> headers; private Map> parameterMap; public JsrHandshakeRequest(ServerUpgradeRequest req) @@ -40,12 +41,13 @@ public JsrHandshakeRequest(ServerUpgradeRequest req) this.delegate = req; this.httpServletRequest = (HttpServletRequest)req .getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE); + this.headers = HttpFields.asMap(delegate.getHeaders()); } @Override public Map> getHeaders() { - return HttpFields.asMap(delegate.getHeaders()); + return headers; } @Override diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/DelegatedServerUpgradeRequest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/DelegatedServerUpgradeRequest.java index 3f8f0155fa4..77d7e71e1a1 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/DelegatedServerUpgradeRequest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/DelegatedServerUpgradeRequest.java @@ -47,6 +47,7 @@ public class DelegatedServerUpgradeRequest implements JettyServerUpgradeRequest private final ServerUpgradeRequest upgradeRequest; private final HttpServletRequest httpServletRequest; private final Principal userPrincipal; + private final Map> headers; private List cookies; private Map> parameterMap; @@ -57,6 +58,7 @@ public DelegatedServerUpgradeRequest(ServerUpgradeRequest request) this.upgradeRequest = request; this.queryString = httpServletRequest.getQueryString(); this.userPrincipal = httpServletRequest.getUserPrincipal(); + this.headers = HttpFields.asMap(upgradeRequest.getHeaders()); try { @@ -121,7 +123,7 @@ public int getHeaderInt(String name) @Override public Map> getHeaders() { - return HttpFields.asMap(upgradeRequest.getHeaders()); + return headers; } @Override diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/DelegatedServerUpgradeResponse.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/DelegatedServerUpgradeResponse.java index 51f0d8eed7f..9ec85c0177f 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/DelegatedServerUpgradeResponse.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/DelegatedServerUpgradeResponse.java @@ -14,7 +14,6 @@ package org.eclipse.jetty.ee10.websocket.server.internal; import java.io.IOException; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -35,22 +34,15 @@ public class DelegatedServerUpgradeResponse implements JettyServerUpgradeRespons { private final ServerUpgradeResponse upgradeResponse; private final HttpServletResponse httpServletResponse; - private final boolean isUpgraded; private final Map> headers; public DelegatedServerUpgradeResponse(ServerUpgradeResponse response) - { - this(response, false); - } - - public DelegatedServerUpgradeResponse(ServerUpgradeResponse response, boolean isUpgraded) { upgradeResponse = response; - this.isUpgraded = isUpgraded; ServletContextResponse servletContextResponse = Response.as(response, ServletContextResponse.class); this.httpServletResponse = (HttpServletResponse)servletContextResponse.getRequest() .getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE); - headers = HttpFields.asMap(upgradeResponse.getHeaders()); + this.headers = HttpFields.asMap(upgradeResponse.getHeaders()); } @Override @@ -100,7 +92,7 @@ public Set getHeaderNames() @Override public Map> getHeaders() { - return isUpgraded ? Collections.unmodifiableMap(headers) : headers; + return headers; } @Override diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/JettyServerFrameHandlerFactory.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/JettyServerFrameHandlerFactory.java index 5fd68de68f7..17f50e82a46 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/JettyServerFrameHandlerFactory.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee10/websocket/server/internal/JettyServerFrameHandlerFactory.java @@ -41,7 +41,7 @@ public FrameHandler newFrameHandler(Object websocketPojo, ServerUpgradeRequest u { JettyWebSocketFrameHandler frameHandler = super.newJettyFrameHandler(websocketPojo); frameHandler.setUpgradeRequest(new DelegatedServerUpgradeRequest(upgradeRequest)); - frameHandler.setUpgradeResponse(new DelegatedServerUpgradeResponse(upgradeResponse, true)); + frameHandler.setUpgradeResponse(new DelegatedServerUpgradeResponse(upgradeResponse)); return frameHandler; } } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-server/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/server/internal/JsrHandshakeRequest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-server/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/server/internal/JsrHandshakeRequest.java index 840d718512d..2589ed55d35 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-server/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/server/internal/JsrHandshakeRequest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-server/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/server/internal/JsrHandshakeRequest.java @@ -33,6 +33,7 @@ public class JsrHandshakeRequest implements HandshakeRequest { private final ServerUpgradeRequest delegate; private final HttpServletRequest httpServletRequest; + private final Map> headers; private Map> parameterMap; public JsrHandshakeRequest(ServerUpgradeRequest req) @@ -40,12 +41,13 @@ public JsrHandshakeRequest(ServerUpgradeRequest req) this.delegate = req; this.httpServletRequest = (HttpServletRequest)req .getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE); + this.headers = HttpFields.asMap(delegate.getHeaders()); } @Override public Map> getHeaders() { - return HttpFields.asMap(delegate.getHeaders()); + return headers; } @Override diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java index d0388a1d0e8..f546ca1b9b1 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeRequest.java @@ -41,10 +41,12 @@ public class DelegatedJettyClientUpgradeRequest implements UpgradeRequest { private final CoreClientUpgradeRequest delegate; + private final Map> headers; public DelegatedJettyClientUpgradeRequest(CoreClientUpgradeRequest delegate) { this.delegate = delegate; + this.headers = HttpFields.asMap(delegate.getHeaders()); } @Override @@ -79,7 +81,7 @@ public List getHeaders(String name) @Override public Map> getHeaders() { - return HttpFields.asMap(delegate.getHeaders()); + return headers; } @Override diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java index 2f14bce6288..395c46d5b2b 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-client/src/main/java/org/eclipse/jetty/ee9/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java @@ -32,10 +32,12 @@ public class DelegatedJettyClientUpgradeResponse implements UpgradeResponse { private final Response delegate; + private final Map> headers; public DelegatedJettyClientUpgradeResponse(Response response) { this.delegate = response; + this.headers = HttpFields.asMap(delegate.getHeaders()); } @Override @@ -65,7 +67,7 @@ public List getHeaders(String name) @Override public Map> getHeaders() { - return HttpFields.asMap(delegate.getHeaders()); + return headers; } @Override diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/internal/DelegatedServerUpgradeRequest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/internal/DelegatedServerUpgradeRequest.java index 256a3451d9e..8f4a192af20 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/internal/DelegatedServerUpgradeRequest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/internal/DelegatedServerUpgradeRequest.java @@ -46,6 +46,7 @@ public class DelegatedServerUpgradeRequest implements JettyServerUpgradeRequest private final String queryString; private final ServerUpgradeRequest upgradeRequest; private final HttpServletRequest httpServletRequest; + private final Map> headers; private List cookies; private Map> parameterMap; @@ -55,6 +56,7 @@ public DelegatedServerUpgradeRequest(ServerUpgradeRequest request) .getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE); this.upgradeRequest = request; this.queryString = httpServletRequest.getQueryString(); + this.headers = HttpFields.asMap(upgradeRequest.getHeaders()); try { @@ -114,7 +116,7 @@ public int getHeaderInt(String name) @Override public Map> getHeaders() { - return HttpFields.asMap(upgradeRequest.getHeaders()); + return headers; } @Override diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/internal/DelegatedServerUpgradeResponse.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/internal/DelegatedServerUpgradeResponse.java index f1a1ff95b37..95d98fe8100 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/internal/DelegatedServerUpgradeResponse.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/main/java/org/eclipse/jetty/ee9/websocket/server/internal/DelegatedServerUpgradeResponse.java @@ -32,12 +32,14 @@ public class DelegatedServerUpgradeResponse implements JettyServerUpgradeRespons { private final ServerUpgradeResponse upgradeResponse; private final HttpServletResponse httpServletResponse; + private final Map> headers; public DelegatedServerUpgradeResponse(ServerUpgradeResponse response) { this.upgradeResponse = response; this.httpServletResponse = (HttpServletResponse)response.getRequest() .getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE); + this.headers = HttpFields.asMap(upgradeResponse.getHeaders()); } @Override @@ -87,7 +89,7 @@ public Set getHeaderNames() @Override public Map> getHeaders() { - return HttpFields.asMap(upgradeResponse.getHeaders()); + return headers; } @Override