tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1337643 - /tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java
Date Sat, 12 May 2012 20:51:24 GMT
Author: markt
Date: Sat May 12 20:51:24 2012
New Revision: 1337643

URL: http://svn.apache.org/viewvc?rev=1337643&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53067
Make sure request is unwrapped before we cast it to the internal Tomcat implementation

Modified:
    tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java

Modified: tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java?rev=1337643&r1=1337642&r2=1337643&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java Sat May 12 20:51:24
2012
@@ -27,6 +27,8 @@ import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestWrapper;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -112,9 +114,19 @@ public abstract class WebSocketServlet e
             // TODO
         }
 
-        // Small hack until the Servlet API provides a way to do this.
         StreamInbound inbound = createWebSocketInbound(subProtocol);
-        ((RequestFacade) req).doUpgrade(inbound);
+
+        // Small hack until the Servlet API provides a way to do this.
+        ServletRequest inner = req;
+        // Unwrap the request
+        while (inner instanceof ServletRequestWrapper) {
+            inner = ((ServletRequestWrapper) inner).getRequest();
+        }
+        if (inner instanceof RequestFacade) {
+            ((RequestFacade) req).doUpgrade(inbound);
+        } else {
+            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+        }
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message