mirror of
https://github.com/jetty/jetty.project.git
synced 2025-02-28 19:09:10 +00:00
482270 - Expose upgrade request locales.
Exposed as a user property.
This commit is contained in:
parent
66e596511d
commit
e6f23a692e
@ -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<String, Object> 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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user