From b763f377d8aecb73245e5d1c1f979b5c2c37cdb7 Mon Sep 17 00:00:00 2001 From: RakhithaRR Date: Mon, 22 Jan 2024 16:49:13 +0530 Subject: [PATCH] Fix inconsistent behaviour with the preserved headers --- .../websocket/transport/WebsocketConnectionFactory.java | 4 ++-- .../websocket/transport/WebsocketTransportSender.java | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketConnectionFactory.java b/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketConnectionFactory.java index 8e3767c79e..360cb15fed 100644 --- a/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketConnectionFactory.java +++ b/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketConnectionFactory.java @@ -235,12 +235,12 @@ public WebSocketClientHandler cacheNewConnection(final String tenantDomain, handler = new WebSocketClientHandler(WebSocketClientHandshakerFactory.newHandshaker(uri, WebSocketVersion.V13, deriveSubprotocol(wsSubprotocol, contentType), - false, defaultHttpHeaders, maxLength)); + false, defaultHttpHeaders, maxLength, true, false, -1L, false, false)); } else { handler = new WebSocketClientHandler(WebSocketClientHandshakerFactory.newHandshaker(uri, WebSocketVersion.V13, deriveSubprotocol(wsSubprotocol, contentType), - false, defaultHttpHeaders)); + false, defaultHttpHeaders, 65536, true, false, -1L, false, false)); } handler.setCorrelationId(correlationId); handler.setApiProperties(apiProperties); diff --git a/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketTransportSender.java b/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketTransportSender.java index 9f23349f4e..1593569140 100644 --- a/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketTransportSender.java +++ b/components/carbon-transports/websocket/org.wso2.carbon.websocket.transport/src/main/java/org/wso2/carbon/websocket/transport/WebsocketTransportSender.java @@ -165,6 +165,13 @@ public void sendMessage(MessageContext msgCtx, String targetEPR, OutTransportInf String preservableHeaders = preserveWebSocketHeadersParameter.getValue().toString(); for (String header : preservableHeaders.split(",")) { Object headerValue = msgCtx.getProperty(header); + Iterator headerNames = msgCtx.getPropertyNames(); + while (headerValue == null && headerNames.hasNext()) { + String headerName = headerNames.next(); + if (headerName.equalsIgnoreCase(header)) { + headerValue = msgCtx.getProperty(headerName); + } + } if (headerValue != null) { customHeaders.put(header, headerValue); }