You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/05/04 11:09:39 UTC
svn commit: r1479061 -
/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsFilter.java
Author: markt
Date: Sat May 4 09:09:39 2013
New Revision: 1479061
URL: http://svn.apache.org/r1479061
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54926
Re-order the validation checks.
Order is now:
- Is this a WebSocket upgrade?
- Is there a matching endpoint?
- Validate remaining headers
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsFilter.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/WsFilter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsFilter.java?rev=1479061&r1=1479060&r2=1479061&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/server/WsFilter.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/server/WsFilter.java Sat May 4 09:09:39 2013
@@ -85,11 +85,29 @@ public class WsFilter implements Filter
}
// HTTP request with an upgrade header for WebSocket present
- // Validate the rest of the headers and reject the request if that
- // validation fails
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
+ // Check to see if this WebSocket implementation has a matching mapping
+ WsServerContainer sc = WsServerContainer.getServerContainer();
+ String path;
+ String pathInfo = req.getPathInfo();
+ if (pathInfo == null) {
+ path = req.getServletPath();
+ } else {
+ path = req.getServletPath() + pathInfo;
+ }
+ WsMappingResult mappingResult = sc.findMapping(path);
+
+ if (mappingResult == null) {
+ // No endpoint registered for the requested path. Let the
+ // application handle it (it might redirect or forward for example)
+ chain.doFilter(request, response);
+ return;
+ }
+
+ // Validate the rest of the headers and reject the request if that
+ // validation fails
String key;
String subProtocol = null;
List<Extension> extensions = Collections.emptyList();
@@ -111,24 +129,6 @@ public class WsFilter implements Filter
return;
}
- // Need an Endpoint instance to progress this further
- WsServerContainer sc = WsServerContainer.getServerContainer();
- String path;
- String pathInfo = req.getPathInfo();
- if (pathInfo == null) {
- path = req.getServletPath();
- } else {
- path = req.getServletPath() + pathInfo;
- }
- WsMappingResult mappingResult = sc.findMapping(path);
-
- if (mappingResult == null) {
- // No endpoint registered for the requested path. Let the
- // application handle it (it might redirect or forward for example)
- chain.doFilter(request, response);
- return;
- }
-
ServerEndpointConfig sec = mappingResult.getConfig();
// Origin check
@@ -145,6 +145,7 @@ public class WsFilter implements Filter
getNegotiatedSubprotocol(
sec.getSubprotocols(), subProtocols);
}
+
// Extensions
// Currently no extensions are supported by this implementation
@@ -199,7 +200,6 @@ public class WsFilter implements Filter
req.upgrade(WsHttpUpgradeHandler.class);
wsHandler.preInit(ep, sec, sc, wsRequest, subProtocol,
mappingResult.getPathParams(), req.isSecure());
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org