PR #8413 - move wrapped req/resp attributes into WebSocketConstants
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
9f92b6b7be
commit
82618073d5
|
@ -32,6 +32,10 @@ public final class WebSocketConstants
|
|||
public static final Duration DEFAULT_IDLE_TIMEOUT = Duration.ofSeconds(30);
|
||||
public static final Duration DEFAULT_WRITE_TIMEOUT = Duration.ZERO;
|
||||
|
||||
// Attributes for storing API requests as attributes on the base jetty-core request.
|
||||
public static final String WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE = "org.eclipse.jetty.websocket.wrappedRequest";
|
||||
public static final String WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE = "org.eclipse.jetty.websocket.wrappedResponse";
|
||||
|
||||
/**
|
||||
* Globally Unique Identifier for use in WebSocket handshake within {@code Sec-WebSocket-Accept} and <code>Sec-WebSocket-Key</code> http headers.
|
||||
* <p>
|
||||
|
|
|
@ -86,8 +86,6 @@ import org.slf4j.LoggerFactory;
|
|||
public class ServletContextRequest extends ContextRequest implements Runnable
|
||||
{
|
||||
public static final String __MULTIPART_CONFIG_ELEMENT = "org.eclipse.jetty.multipartConfig";
|
||||
public static final String WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE = "org.eclipse.jetty.websocket.wrappedRequest";
|
||||
public static final String WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE = "org.eclipse.jetty.websocket.wrappedResponse";
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServletContextRequest.class);
|
||||
private static final Collection<Locale> __defaultLocale = Collections.singleton(Locale.getDefault());
|
||||
private static final int INPUT_NONE = 0;
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.eclipse.jetty.util.Blocker;
|
|||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException;
|
||||
import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils;
|
||||
|
@ -307,8 +308,8 @@ public class JakartaWebSocketServerContainer extends JakartaWebSocketClientConta
|
|||
{
|
||||
// Set the wrapped req and resp as attributes on the ServletContext Request/Response, so they
|
||||
// are accessible when websocket-core calls back the Jetty WebSocket creator.
|
||||
baseRequest.setAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
|
||||
if (handshaker.upgradeRequest(negotiator, baseRequest, baseResponse, callback, components, defaultCustomizer))
|
||||
{
|
||||
|
@ -317,8 +318,8 @@ public class JakartaWebSocketServerContainer extends JakartaWebSocketClientConta
|
|||
}
|
||||
finally
|
||||
{
|
||||
baseRequest.removeAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.eclipse.jetty.util.component.Dumpable;
|
|||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.websocket.core.Configuration;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.exception.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils;
|
||||
import org.eclipse.jetty.websocket.core.server.Handshaker;
|
||||
|
@ -226,8 +227,8 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
|||
{
|
||||
// Set the wrapped req and resp as attributes on the ServletContext Request/Response, so they
|
||||
// are accessible when websocket-core calls back the Jetty WebSocket creator.
|
||||
baseRequest.setAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
|
||||
if (handshaker.upgradeRequest(negotiator, baseRequest, baseResponse, callback, components, customizer))
|
||||
{
|
||||
|
@ -237,8 +238,8 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
|||
}
|
||||
finally
|
||||
{
|
||||
baseRequest.removeAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.jetty.util.Blocker;
|
|||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.websocket.core.Configuration;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse;
|
||||
|
@ -193,8 +194,8 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
{
|
||||
// Set the wrapped req and resp as attributes on the ServletContext Request/Response, so they
|
||||
// are accessible when websocket-core calls back the Jetty WebSocket creator.
|
||||
request.setAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, req);
|
||||
request.setAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, resp);
|
||||
request.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, req);
|
||||
request.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, resp);
|
||||
|
||||
if (mapping.upgrade(request, response, callback, null))
|
||||
{
|
||||
|
@ -204,8 +205,8 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
}
|
||||
finally
|
||||
{
|
||||
request.removeAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
request.removeAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
request.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
request.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ import java.util.stream.Collectors;
|
|||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.eclipse.jetty.ee10.servlet.ServletContextRequest;
|
||||
import org.eclipse.jetty.ee10.websocket.api.ExtensionConfig;
|
||||
import org.eclipse.jetty.ee10.websocket.common.JettyExtensionConfig;
|
||||
import org.eclipse.jetty.ee10.websocket.server.JettyServerUpgradeRequest;
|
||||
import org.eclipse.jetty.http.BadMessageException;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest;
|
||||
|
||||
public class DelegatedServerUpgradeRequest implements JettyServerUpgradeRequest
|
||||
|
@ -52,7 +52,7 @@ public class DelegatedServerUpgradeRequest implements JettyServerUpgradeRequest
|
|||
public DelegatedServerUpgradeRequest(ServerUpgradeRequest request)
|
||||
{
|
||||
this.httpServletRequest = (HttpServletRequest)request
|
||||
.getAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
.getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
this.upgradeRequest = request;
|
||||
this.queryString = httpServletRequest.getQueryString();
|
||||
|
||||
|
|
|
@ -22,13 +22,13 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.eclipse.jetty.ee10.servlet.ServletContextRequest;
|
||||
import org.eclipse.jetty.ee10.servlet.ServletContextResponse;
|
||||
import org.eclipse.jetty.ee10.websocket.api.ExtensionConfig;
|
||||
import org.eclipse.jetty.ee10.websocket.common.JettyExtensionConfig;
|
||||
import org.eclipse.jetty.ee10.websocket.server.JettyServerUpgradeResponse;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse;
|
||||
|
||||
public class DelegatedServerUpgradeResponse implements JettyServerUpgradeResponse
|
||||
|
@ -41,7 +41,7 @@ public class DelegatedServerUpgradeResponse implements JettyServerUpgradeRespons
|
|||
upgradeResponse = response;
|
||||
ServletContextResponse servletContextResponse = Response.as(response, ServletContextResponse.class);
|
||||
this.httpServletResponse = (HttpServletResponse)servletContextResponse.getRequest()
|
||||
.getAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
.getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.jetty.util.component.Dumpable;
|
|||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.thread.AutoLock;
|
||||
import org.eclipse.jetty.websocket.core.Configuration;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.server.WebSocketMappings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -169,8 +170,8 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
{
|
||||
// Set the wrapped req and resp as attributes on the ServletContext Request/Response, so they
|
||||
// are accessible when websocket-core calls back the Jetty WebSocket creator.
|
||||
baseRequest.setAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
|
||||
if (mappings.upgrade(baseRequest, baseResponse, callback, defaultCustomizer))
|
||||
{
|
||||
|
@ -180,8 +181,8 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
}
|
||||
finally
|
||||
{
|
||||
baseRequest.removeAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(ServletContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2350,9 +2350,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
|
||||
public static class CoreContextRequest extends ContextRequest
|
||||
{
|
||||
public static final String WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE = "org.eclipse.jetty.websocket.wrappedRequest";
|
||||
public static final String WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE = "org.eclipse.jetty.websocket.wrappedResponse";
|
||||
|
||||
private final HttpChannel _httpChannel;
|
||||
|
||||
protected CoreContextRequest(org.eclipse.jetty.server.handler.ContextHandler contextHandler,
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.jetty.util.Blocker;
|
|||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException;
|
||||
import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils;
|
||||
|
@ -307,8 +308,8 @@ public class JakartaWebSocketServerContainer extends JakartaWebSocketClientConta
|
|||
{
|
||||
// Set the wrapped req and resp as attachments on the ServletContext Request/Response, so they
|
||||
// are accessible when websocket-core calls back the Jetty WebSocket creator.
|
||||
baseRequest.setAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
|
||||
if (handshaker.upgradeRequest(negotiator, baseRequest, baseResponse, callback, components, defaultCustomizer))
|
||||
{
|
||||
|
@ -317,8 +318,8 @@ public class JakartaWebSocketServerContainer extends JakartaWebSocketClientConta
|
|||
}
|
||||
finally
|
||||
{
|
||||
request.removeAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
request.removeAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
request.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
request.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.function.Consumer;
|
|||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.eclipse.jetty.ee9.nested.ContextHandler;
|
||||
import org.eclipse.jetty.ee9.nested.HttpChannel;
|
||||
import org.eclipse.jetty.ee9.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.ee9.websocket.api.Session;
|
||||
|
@ -47,6 +46,7 @@ import org.eclipse.jetty.util.component.Dumpable;
|
|||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.websocket.core.Configuration;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.exception.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils;
|
||||
import org.eclipse.jetty.websocket.core.server.Handshaker;
|
||||
|
@ -226,8 +226,8 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
|||
{
|
||||
// Set the wrapped req and resp as attachments on the ServletContext Request/Response, so they
|
||||
// are accessible when websocket-core calls back the Jetty WebSocket creator.
|
||||
baseRequest.setAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
|
||||
if (handshaker.upgradeRequest(negotiator, baseRequest, baseResponse, callback, components, customizer))
|
||||
{
|
||||
|
@ -237,8 +237,8 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
|||
}
|
||||
finally
|
||||
{
|
||||
baseRequest.removeAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.jetty.util.Blocker;
|
|||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.websocket.core.Configuration;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse;
|
||||
|
@ -196,8 +197,8 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
{
|
||||
// Set the wrapped req and resp as attributes on the ServletContext Request/Response, so they
|
||||
// are accessible when websocket-core calls back the Jetty WebSocket creator.
|
||||
request.setAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, req);
|
||||
request.setAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, resp);
|
||||
request.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, req);
|
||||
request.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, resp);
|
||||
|
||||
if (mapping.upgrade(request, response, callback, null))
|
||||
{
|
||||
|
@ -207,8 +208,8 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
}
|
||||
finally
|
||||
{
|
||||
request.removeAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
request.removeAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
request.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
request.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ import java.util.stream.Collectors;
|
|||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.eclipse.jetty.ee9.nested.ContextHandler;
|
||||
import org.eclipse.jetty.ee9.websocket.api.ExtensionConfig;
|
||||
import org.eclipse.jetty.ee9.websocket.common.JettyExtensionConfig;
|
||||
import org.eclipse.jetty.ee9.websocket.server.JettyServerUpgradeRequest;
|
||||
import org.eclipse.jetty.http.BadMessageException;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest;
|
||||
|
||||
public class DelegatedServerUpgradeRequest implements JettyServerUpgradeRequest
|
||||
|
@ -52,7 +52,7 @@ public class DelegatedServerUpgradeRequest implements JettyServerUpgradeRequest
|
|||
public DelegatedServerUpgradeRequest(ServerUpgradeRequest request)
|
||||
{
|
||||
this.httpServletRequest = (HttpServletRequest)request
|
||||
.getAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
.getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
this.upgradeRequest = request;
|
||||
this.queryString = httpServletRequest.getQueryString();
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.eclipse.jetty.ee9.nested.ContextHandler;
|
||||
import org.eclipse.jetty.ee9.websocket.api.ExtensionConfig;
|
||||
import org.eclipse.jetty.ee9.websocket.common.JettyExtensionConfig;
|
||||
import org.eclipse.jetty.ee9.websocket.server.JettyServerUpgradeResponse;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse;
|
||||
|
||||
public class DelegatedServerUpgradeResponse implements JettyServerUpgradeResponse
|
||||
|
@ -38,7 +38,7 @@ public class DelegatedServerUpgradeResponse implements JettyServerUpgradeRespons
|
|||
{
|
||||
this.upgradeResponse = response;
|
||||
this.httpServletResponse = (HttpServletResponse)response.getRequest()
|
||||
.getAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
.getAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.jetty.util.component.Dumpable;
|
|||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.thread.AutoLock;
|
||||
import org.eclipse.jetty.websocket.core.Configuration;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketConstants;
|
||||
import org.eclipse.jetty.websocket.core.server.WebSocketMappings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -168,8 +169,8 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
{
|
||||
// Set the wrapped req and resp as attributes on the ServletContext Request/Response, so they
|
||||
// are accessible when websocket-core calls back the Jetty WebSocket creator.
|
||||
baseRequest.setAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE, request);
|
||||
baseRequest.setAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE, response);
|
||||
|
||||
if (mappings.upgrade(baseRequest, baseResponse, callback, defaultCustomizer))
|
||||
{
|
||||
|
@ -179,8 +180,8 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
}
|
||||
finally
|
||||
{
|
||||
baseRequest.removeAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(ContextHandler.CoreContextRequest.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_REQUEST_ATTRIBUTE);
|
||||
baseRequest.removeAttribute(WebSocketConstants.WEBSOCKET_WRAPPED_RESPONSE_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue