From e6f23a692ec3a7472965100854a7ade69733c71c Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 8 Dec 2015 12:02:57 +0100 Subject: [PATCH] 482270 - Expose upgrade request locales. Exposed as a user property. --- .../jetty/websocket/jsr356/server/JsrCreator.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java index 1c43be3895b..b261f61dd8b 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java @@ -20,7 +20,9 @@ package org.eclipse.jetty.websocket.jsr356.server; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Map; import javax.websocket.Extension; import javax.websocket.Extension.Parameter; @@ -43,6 +45,7 @@ public class JsrCreator implements WebSocketCreator { public static final String PROP_REMOTE_ADDRESS = "javax.websocket.endpoint.remoteAddress"; public static final String PROP_LOCAL_ADDRESS = "javax.websocket.endpoint.localAddress"; + public static final String PROP_LOCALES = "javax.websocket.upgrade.locales"; private static final Logger LOG = Log.getLogger(JsrCreator.class); private final ServerEndpointMetadata metadata; private final ExtensionFactory extensionFactory; @@ -61,17 +64,19 @@ public class JsrCreator implements WebSocketCreator // Get raw config, as defined when the endpoint was added to the container ServerEndpointConfig config = metadata.getConfig(); - + // Establish a copy of the config, so that the UserProperties are unique // per upgrade request. config = new BasicServerEndpointConfig(config); - + // Bug 444617 - Expose localAddress and remoteAddress for jsr modify handshake to use // This is being implemented as an optional set of userProperties so that // it is not JSR api breaking. A few users on #jetty and a few from cometd // have asked for access to this information. - config.getUserProperties().put(PROP_LOCAL_ADDRESS,req.getLocalSocketAddress()); - config.getUserProperties().put(PROP_REMOTE_ADDRESS,req.getRemoteSocketAddress()); + Map userProperties = config.getUserProperties(); + userProperties.put(PROP_LOCAL_ADDRESS,req.getLocalSocketAddress()); + userProperties.put(PROP_REMOTE_ADDRESS,req.getRemoteSocketAddress()); + userProperties.put(PROP_LOCALES,Collections.list(req.getLocales())); // Get Configurator from config object (not guaranteed to be unique per endpoint upgrade) ServerEndpointConfig.Configurator configurator = config.getConfigurator();