Author: markt Date: Fri Oct 3 19:08:17 2014 New Revision: 1629293 URL: http://svn.apache.org/r1629293 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57054 Correctly handle the case in the WebSocket client when the HTTP response to the upgrade request can not be read in a single pass; either because the buffer is too small or the server sent the response in multiple packets.
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1629293&r1=1629292&r2=1629293&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Fri Oct 3 19:08:17 2014 @@ -545,6 +545,9 @@ public class WsWebSocketContainer boolean readHeaders = false; String line = null; while (!readHeaders) { + // On entering loop buffer will be empty and at the start of a new + // loop the buffer will have been fully read. + response.clear(); // Blocking read Future<Integer> read = channel.read(response); Integer bytesRead = read.get(timeout, TimeUnit.MILLISECONDS); Modified: tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java?rev=1629293&r1=1629292&r2=1629293&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java (original) +++ tomcat/trunk/test/org/apache/tomcat/websocket/TestWsWebSocketContainer.java Fri Oct 3 19:08:17 2014 @@ -91,6 +91,9 @@ public class TestWsWebSocketContainer ex WebSocketContainer wsContainer = ContainerProvider.getWebSocketContainer(); + // Set this artificially small to trigger + // https://issues.apache.org/bugzilla/show_bug.cgi?id=57054 + wsContainer.setDefaultMaxBinaryMessageBufferSize(64); Session wsSession = wsContainer.connectToServer( TesterProgrammaticEndpoint.class, ClientEndpointConfig.Builder.create().build(), Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1629293&r1=1629292&r2=1629293&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Oct 3 19:08:17 2014 @@ -121,6 +121,16 @@ </fix> </changelog> </subsection> + <subsection name="WebSocket"> + <changelog> + <fix> + <bug>57054</bug>: Correctly handle the case in the WebSocket client + when the HTTP response to the upgrade request can not be read in a + single pass; either because the buffer is too small or the server sent + the response in multiple packets. (markt) + </fix> + </changelog> + </subsection> <subsection name="Web applications"> <changelog> <fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org