Issue #5044 - Jetty Server upgrade request/response now implement the API interfaces
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
9027e17095
commit
3074aa7fae
|
@ -22,13 +22,13 @@ import java.net.URI;
|
|||
import java.security.Principal;
|
||||
|
||||
import org.eclipse.jetty.websocket.javax.common.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
|
||||
|
||||
public class JavaxServerUpgradeRequest implements UpgradeRequest
|
||||
{
|
||||
private final ServletUpgradeRequest servletRequest;
|
||||
private final ServerUpgradeRequest servletRequest;
|
||||
|
||||
public JavaxServerUpgradeRequest(ServletUpgradeRequest servletRequest)
|
||||
public JavaxServerUpgradeRequest(ServerUpgradeRequest servletRequest)
|
||||
{
|
||||
this.servletRequest = servletRequest;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ import org.eclipse.jetty.websocket.javax.common.ConfiguredEndpoint;
|
|||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer;
|
||||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketExtension;
|
||||
import org.eclipse.jetty.websocket.javax.common.ServerEndpointConfigWrapper;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketCreator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -62,7 +62,7 @@ public class JavaxWebSocketCreator implements WebSocketCreator
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
|
||||
public Object createWebSocket(ServerUpgradeRequest req, ServerUpgradeResponse resp)
|
||||
{
|
||||
final JsrHandshakeRequest jsrHandshakeRequest = new JsrHandshakeRequest(req);
|
||||
final JsrHandshakeResponse jsrHandshakeResponse = new JsrHandshakeResponse(resp);
|
||||
|
|
|
@ -27,8 +27,8 @@ import org.eclipse.jetty.websocket.javax.client.internal.JavaxWebSocketClientFra
|
|||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer;
|
||||
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;
|
||||
|
||||
public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketClientFrameHandlerFactory implements FrameHandlerFactory
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketClien
|
|||
}
|
||||
|
||||
@Override
|
||||
public FrameHandler newFrameHandler(Object websocketPojo, ServletUpgradeRequest upgradeRequest, ServletUpgradeResponse upgradeResponse)
|
||||
public FrameHandler newFrameHandler(Object websocketPojo, ServerUpgradeRequest upgradeRequest, ServerUpgradeResponse upgradeResponse)
|
||||
{
|
||||
return newJavaxWebSocketFrameHandler(websocketPojo, new JavaxServerUpgradeRequest(upgradeRequest));
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@ import java.util.Map;
|
|||
import javax.websocket.server.HandshakeRequest;
|
||||
|
||||
import org.eclipse.jetty.http.pathmap.PathSpec;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
|
||||
|
||||
public class JsrHandshakeRequest implements HandshakeRequest
|
||||
{
|
||||
private final ServletUpgradeRequest delegate;
|
||||
private final ServerUpgradeRequest delegate;
|
||||
|
||||
public JsrHandshakeRequest(ServletUpgradeRequest req)
|
||||
public JsrHandshakeRequest(ServerUpgradeRequest req)
|
||||
{
|
||||
this.delegate = req;
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import javax.websocket.HandshakeResponse;
|
||||
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;
|
||||
|
||||
public class JsrHandshakeResponse implements HandshakeResponse
|
||||
{
|
||||
private final ServletUpgradeResponse delegate;
|
||||
private final ServerUpgradeResponse delegate;
|
||||
private Map<String, List<String>> headerMap;
|
||||
|
||||
public JsrHandshakeResponse(ServletUpgradeResponse resp)
|
||||
public JsrHandshakeResponse(ServerUpgradeResponse resp)
|
||||
{
|
||||
this.delegate = resp;
|
||||
this.headerMap = new HashMap<>();
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
|||
*/
|
||||
public class DelegatedJettyClientUpgradeResponse implements UpgradeResponse
|
||||
{
|
||||
private HttpResponse delegate;
|
||||
private final HttpResponse delegate;
|
||||
|
||||
public DelegatedJettyClientUpgradeResponse(HttpResponse response)
|
||||
{
|
||||
|
|
|
@ -33,20 +33,134 @@ import javax.servlet.ServletRequest;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.common.JettyExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.core.server.Negotiation;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
|
||||
|
||||
public class JettyServerUpgradeRequest
|
||||
public class JettyServerUpgradeRequest implements UpgradeRequest
|
||||
{
|
||||
private final ServletUpgradeRequest upgradeRequest;
|
||||
private final ServerUpgradeRequest upgradeRequest;
|
||||
|
||||
JettyServerUpgradeRequest(ServletUpgradeRequest request)
|
||||
JettyServerUpgradeRequest(ServerUpgradeRequest request)
|
||||
{
|
||||
upgradeRequest = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HttpCookie> getCookies()
|
||||
{
|
||||
return upgradeRequest.getCookies();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtensionConfig> getExtensions()
|
||||
{
|
||||
return upgradeRequest.getExtensions().stream().map(JettyExtensionConfig::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name)
|
||||
{
|
||||
return upgradeRequest.getHeader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeaderInt(String name)
|
||||
{
|
||||
return upgradeRequest.getHeaderInt(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getHeaders()
|
||||
{
|
||||
return upgradeRequest.getHeadersMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getHeaders(String name)
|
||||
{
|
||||
return upgradeRequest.getHeaders(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost()
|
||||
{
|
||||
return upgradeRequest.getHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHttpVersion()
|
||||
{
|
||||
return upgradeRequest.getHttpVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod()
|
||||
{
|
||||
return upgradeRequest.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrigin()
|
||||
{
|
||||
return upgradeRequest.getOrigin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getParameterMap()
|
||||
{
|
||||
return upgradeRequest.getParameterMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocolVersion()
|
||||
{
|
||||
return upgradeRequest.getProtocolVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryString()
|
||||
{
|
||||
return upgradeRequest.getQueryString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getRequestURI()
|
||||
{
|
||||
return upgradeRequest.getRequestURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession()
|
||||
{
|
||||
return upgradeRequest.getSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubProtocols()
|
||||
{
|
||||
return upgradeRequest.getSubProtocols();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal()
|
||||
{
|
||||
return upgradeRequest.getUserPrincipal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSubProtocol(String subprotocol)
|
||||
{
|
||||
return upgradeRequest.hasSubProtocol(subprotocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure()
|
||||
{
|
||||
return upgradeRequest.isSecure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The {@link X509Certificate} instance at request attribute "javax.servlet.request.X509Certificate" or null.
|
||||
*/
|
||||
|
@ -55,70 +169,6 @@ public class JettyServerUpgradeRequest
|
|||
return upgradeRequest.getCertificates();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Request cookies
|
||||
* @see HttpServletRequest#getCookies()
|
||||
*/
|
||||
public List<HttpCookie> getCookies()
|
||||
{
|
||||
return upgradeRequest.getCookies();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The extensions offered
|
||||
* @see Negotiation#getOfferedExtensions()
|
||||
*/
|
||||
public List<ExtensionConfig> getExtensions()
|
||||
{
|
||||
return upgradeRequest.getExtensions().stream().map(JettyExtensionConfig::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Header name
|
||||
* @return Header value or null
|
||||
* @see HttpServletRequest#getHeader(String)
|
||||
*/
|
||||
public String getHeader(String name)
|
||||
{
|
||||
return upgradeRequest.getHeader(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Header name
|
||||
* @return Header value as integer or -1
|
||||
* @see HttpServletRequest#getHeader(String)
|
||||
*/
|
||||
public int getHeaderInt(String name)
|
||||
{
|
||||
return upgradeRequest.getHeaderInt(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Map of headers
|
||||
*/
|
||||
public Map<String, List<String>> getHeadersMap()
|
||||
{
|
||||
return upgradeRequest.getHeadersMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Header name
|
||||
* @return List of header values or null
|
||||
*/
|
||||
public List<String> getHeaders(String name)
|
||||
{
|
||||
return upgradeRequest.getHeaders(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The requested host
|
||||
* @see HttpServletRequest#getRequestURL()
|
||||
*/
|
||||
public String getHost()
|
||||
{
|
||||
return upgradeRequest.getHost();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Immutable version of {@link HttpServletRequest}
|
||||
*/
|
||||
|
@ -127,15 +177,6 @@ public class JettyServerUpgradeRequest
|
|||
return upgradeRequest.getHttpServletRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The HTTP protocol version
|
||||
* @see HttpServletRequest#getProtocol()
|
||||
*/
|
||||
public String getHttpVersion()
|
||||
{
|
||||
return upgradeRequest.getHttpVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The requested Locale
|
||||
* @see HttpServletRequest#getLocale()
|
||||
|
@ -164,49 +205,6 @@ public class JettyServerUpgradeRequest
|
|||
return upgradeRequest.getLocalSocketAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The requested method
|
||||
* @see HttpServletRequest#getMethod()
|
||||
*/
|
||||
public String getMethod()
|
||||
{
|
||||
return upgradeRequest.getMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The origin header value
|
||||
*/
|
||||
public String getOrigin()
|
||||
{
|
||||
return upgradeRequest.getOrigin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The request parameter map
|
||||
* @see ServletRequest#getParameterMap()
|
||||
*/
|
||||
public Map<String, List<String>> getParameterMap()
|
||||
{
|
||||
return upgradeRequest.getParameterMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WebSocket protocol version from "Sec-WebSocket-Version" header
|
||||
*/
|
||||
public String getProtocolVersion()
|
||||
{
|
||||
return upgradeRequest.getProtocolVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The request query string
|
||||
* @see HttpServletRequest#getQueryString()
|
||||
*/
|
||||
public String getQueryString()
|
||||
{
|
||||
return upgradeRequest.getQueryString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The remote request address, which is typically an {@link InetSocketAddress}, but may be another derivation of {@link SocketAddress}
|
||||
* @see ServletRequest#getRemoteAddr()
|
||||
|
@ -225,15 +223,6 @@ public class JettyServerUpgradeRequest
|
|||
return upgradeRequest.getRequestPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The request URI
|
||||
* @see HttpServletRequest#getRequestURL()
|
||||
*/
|
||||
public URI getRequestURI()
|
||||
{
|
||||
return upgradeRequest.getRequestURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Attribute name
|
||||
* @return Attribute value or null
|
||||
|
@ -261,50 +250,6 @@ public class JettyServerUpgradeRequest
|
|||
return upgradeRequest.getServletParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The HttpSession, which may be null or invalidated
|
||||
* @see HttpServletRequest#getSession(boolean)
|
||||
*/
|
||||
public HttpSession getSession()
|
||||
{
|
||||
return upgradeRequest.getSession();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Get WebSocket negotiation offered sub protocols
|
||||
*/
|
||||
public List<String> getSubProtocols()
|
||||
{
|
||||
return upgradeRequest.getSubProtocols();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The User's {@link Principal} or null
|
||||
* @see HttpServletRequest#getUserPrincipal()
|
||||
*/
|
||||
public Principal getUserPrincipal()
|
||||
{
|
||||
return upgradeRequest.getUserPrincipal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param subprotocol A sub protocol name
|
||||
* @return True if the sub protocol was offered
|
||||
*/
|
||||
public boolean hasSubProtocol(String subprotocol)
|
||||
{
|
||||
return upgradeRequest.hasSubProtocol(subprotocol);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if the request is secure
|
||||
* @see ServletRequest#isSecure()
|
||||
*/
|
||||
public boolean isSecure()
|
||||
{
|
||||
return upgradeRequest.isSecure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param role The user role
|
||||
* @return True if the requests user has the role
|
||||
|
|
|
@ -24,69 +24,105 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.common.JettyExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;
|
||||
|
||||
public class JettyServerUpgradeResponse
|
||||
public class JettyServerUpgradeResponse implements UpgradeResponse
|
||||
{
|
||||
private ServletUpgradeResponse upgradeResponse;
|
||||
private final ServerUpgradeResponse upgradeResponse;
|
||||
|
||||
JettyServerUpgradeResponse(ServletUpgradeResponse response)
|
||||
JettyServerUpgradeResponse(ServerUpgradeResponse response)
|
||||
{
|
||||
upgradeResponse = response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHeader(String name, String value)
|
||||
{
|
||||
upgradeResponse.addHeader(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(String name, String value)
|
||||
{
|
||||
upgradeResponse.setHeader(name, value);
|
||||
}
|
||||
|
||||
public void setHeader(String name, List<String> values)
|
||||
{
|
||||
upgradeResponse.setHeader(name, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAcceptedSubProtocol()
|
||||
{
|
||||
return upgradeResponse.getAcceptedSubProtocol();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtensionConfig> getExtensions()
|
||||
{
|
||||
return upgradeResponse.getExtensions().stream().map(JettyExtensionConfig::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name)
|
||||
{
|
||||
return upgradeResponse.getHeader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getHeaderNames()
|
||||
{
|
||||
return upgradeResponse.getHeaderNames();
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getHeadersMap()
|
||||
@Override
|
||||
public Map<String, List<String>> getHeaders()
|
||||
{
|
||||
return upgradeResponse.getHeadersMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getHeaders(String name)
|
||||
{
|
||||
return upgradeResponse.getHeaders(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusCode()
|
||||
{
|
||||
return upgradeResponse.getStatusCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendForbidden(String message) throws IOException
|
||||
{
|
||||
upgradeResponse.sendForbidden(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAcceptedSubProtocol(String protocol)
|
||||
{
|
||||
upgradeResponse.setAcceptedSubProtocol(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtensions(List<ExtensionConfig> configs)
|
||||
{
|
||||
upgradeResponse.setExtensions(configs.stream()
|
||||
.map(c -> new org.eclipse.jetty.websocket.core.ExtensionConfig(c.getName(), c.getParameters()))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatusCode(int statusCode)
|
||||
{
|
||||
upgradeResponse.setStatusCode(statusCode);
|
||||
}
|
||||
|
||||
public void setHeader(String name, List<String> values)
|
||||
{
|
||||
upgradeResponse.setHeader(name, values);
|
||||
}
|
||||
|
||||
public boolean isCommitted()
|
||||
{
|
||||
return upgradeResponse.isCommitted();
|
||||
|
@ -96,26 +132,4 @@ public class JettyServerUpgradeResponse
|
|||
{
|
||||
upgradeResponse.sendError(statusCode, message);
|
||||
}
|
||||
|
||||
public void sendForbidden(String message) throws IOException
|
||||
{
|
||||
upgradeResponse.sendForbidden(message);
|
||||
}
|
||||
|
||||
public void setAcceptedSubProtocol(String protocol)
|
||||
{
|
||||
upgradeResponse.setAcceptedSubProtocol(protocol);
|
||||
}
|
||||
|
||||
public void setExtensions(List<ExtensionConfig> configs)
|
||||
{
|
||||
upgradeResponse.setExtensions(configs.stream()
|
||||
.map(c -> new org.eclipse.jetty.websocket.core.ExtensionConfig(c.getName(), c.getParameters()))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public void setStatusCode(int statusCode)
|
||||
{
|
||||
upgradeResponse.setStatusCode(statusCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents;
|
|||
import org.eclipse.jetty.websocket.server.internal.JettyServerFrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketCreator;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -276,7 +276,7 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
|
||||
public Object createWebSocket(ServerUpgradeRequest req, ServerUpgradeResponse resp)
|
||||
{
|
||||
return creator.createWebSocket(new JettyServerUpgradeRequest(req), new JettyServerUpgradeResponse(resp));
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler;
|
|||
import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;
|
||||
|
||||
public class JettyServerFrameHandlerFactory extends JettyWebSocketFrameHandlerFactory implements FrameHandlerFactory, LifeCycle.Listener
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ public class JettyServerFrameHandlerFactory extends JettyWebSocketFrameHandlerFa
|
|||
}
|
||||
|
||||
@Override
|
||||
public FrameHandler newFrameHandler(Object websocketPojo, ServletUpgradeRequest upgradeRequest, ServletUpgradeResponse upgradeResponse)
|
||||
public FrameHandler newFrameHandler(Object websocketPojo, ServerUpgradeRequest upgradeRequest, ServerUpgradeResponse upgradeResponse)
|
||||
{
|
||||
JettyWebSocketFrameHandler frameHandler = super.newJettyFrameHandler(websocketPojo);
|
||||
frameHandler.setUpgradeRequest(new UpgradeRequestAdapter(upgradeRequest));
|
||||
|
|
|
@ -28,13 +28,13 @@ import java.util.stream.Collectors;
|
|||
import org.eclipse.jetty.websocket.api.UpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.common.JettyExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
|
||||
|
||||
public class UpgradeRequestAdapter implements UpgradeRequest
|
||||
{
|
||||
private final ServletUpgradeRequest _servletRequest;
|
||||
private final ServerUpgradeRequest _servletRequest;
|
||||
|
||||
public UpgradeRequestAdapter(ServletUpgradeRequest servletRequest)
|
||||
public UpgradeRequestAdapter(ServerUpgradeRequest servletRequest)
|
||||
{
|
||||
_servletRequest = servletRequest;
|
||||
}
|
||||
|
|
|
@ -27,13 +27,13 @@ import java.util.stream.Collectors;
|
|||
import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.common.JettyExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServletUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;
|
||||
|
||||
public class UpgradeResponseAdapter implements UpgradeResponse
|
||||
{
|
||||
private final ServletUpgradeResponse servletResponse;
|
||||
private final ServerUpgradeResponse servletResponse;
|
||||
|
||||
public UpgradeResponseAdapter(ServletUpgradeResponse servletResponse)
|
||||
public UpgradeResponseAdapter(ServerUpgradeResponse servletResponse)
|
||||
{
|
||||
this.servletResponse = servletResponse;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,5 @@ public interface FrameHandlerFactory
|
|||
* @return the API specific FrameHandler, or null if this implementation is unable to create
|
||||
* the FrameHandler (allowing another {@link FrameHandlerFactory} to try)
|
||||
*/
|
||||
FrameHandler newFrameHandler(Object websocketPojo, ServletUpgradeRequest upgradeRequest,
|
||||
ServletUpgradeResponse upgradeResponse);
|
||||
FrameHandler newFrameHandler(Object websocketPojo, ServerUpgradeRequest upgradeRequest, ServerUpgradeResponse upgradeResponse);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.eclipse.jetty.websocket.core.server.Negotiation;
|
|||
/**
|
||||
* Holder of request data for a WebSocket upgrade request.
|
||||
*/
|
||||
public class ServletUpgradeRequest
|
||||
public class ServerUpgradeRequest
|
||||
{
|
||||
private final URI requestURI;
|
||||
private final String queryString;
|
||||
|
@ -56,7 +56,7 @@ public class ServletUpgradeRequest
|
|||
private List<HttpCookie> cookies;
|
||||
private Map<String, List<String>> parameterMap;
|
||||
|
||||
public ServletUpgradeRequest(Negotiation negotiation) throws BadMessageException
|
||||
public ServerUpgradeRequest(Negotiation negotiation) throws BadMessageException
|
||||
{
|
||||
this.negotiation = negotiation;
|
||||
HttpServletRequest httpRequest = negotiation.getRequest();
|
|
@ -36,12 +36,12 @@ import org.eclipse.jetty.websocket.core.server.Negotiation;
|
|||
/**
|
||||
* Servlet Specific UpgradeResponse implementation.
|
||||
*/
|
||||
public class ServletUpgradeResponse
|
||||
public class ServerUpgradeResponse
|
||||
{
|
||||
private final HttpServletResponse response;
|
||||
private final Negotiation negotiation;
|
||||
|
||||
public ServletUpgradeResponse(Negotiation negotiation)
|
||||
public ServerUpgradeResponse(Negotiation negotiation)
|
||||
{
|
||||
this.negotiation = negotiation;
|
||||
this.response = negotiation.getResponse();
|
|
@ -81,7 +81,7 @@ public class UpgradeHttpServletRequest implements HttpServletRequest
|
|||
private final Map<String, Object> attributes = new HashMap<>(2);
|
||||
private final List<Locale> locales = new ArrayList<>(2);
|
||||
|
||||
private HttpSession session;
|
||||
private final HttpSession session;
|
||||
|
||||
private final InetSocketAddress localAddress;
|
||||
private final String localName;
|
||||
|
|
|
@ -34,5 +34,5 @@ public interface WebSocketCreator
|
|||
* @param resp the response details
|
||||
* @return a websocket object to use, or null if no websocket should be created from this request.
|
||||
*/
|
||||
Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp);
|
||||
Object createWebSocket(ServerUpgradeRequest req, ServerUpgradeResponse resp);
|
||||
}
|
||||
|
|
|
@ -265,8 +265,8 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
|||
if (servletContext == null)
|
||||
throw new IllegalStateException("null servletContext from request");
|
||||
|
||||
ServletUpgradeRequest upgradeRequest = new ServletUpgradeRequest(negotiation);
|
||||
ServletUpgradeResponse upgradeResponse = new ServletUpgradeResponse(negotiation);
|
||||
ServerUpgradeRequest upgradeRequest = new ServerUpgradeRequest(negotiation);
|
||||
ServerUpgradeResponse upgradeResponse = new ServerUpgradeResponse(negotiation);
|
||||
|
||||
AtomicReference<Object> result = new AtomicReference<>();
|
||||
((ContextHandler.Context)servletContext).getContextHandler().handle(() ->
|
||||
|
|
Loading…
Reference in New Issue