Author: markt Date: Fri Dec 21 23:02:35 2012 New Revision: 1425175 URL: http://svn.apache.org/viewvc?rev=1425175&view=rev Log: Send a close frame telling the client why the connection is being closed if the server buffers can't cope.
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java?rev=1425175&r1=1425174&r2=1425175&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java Fri Dec 21 23:02:35 2012 @@ -327,9 +327,13 @@ public class WsFrame { return; } if (inputBuffer.length < frameSize) { - // Never going to work // TODO i18n - buffer too small - throw new IOException(); + CloseReason cr = new CloseReason(CloseCodes.TOO_BIG, + "Buffer size: [" + inputBuffer.length + + "], frame size: [" + frameSize + "]"); + wsSession.close(cr); + wsSession.onClose(cr); + throw new IOException(cr.getReasonPhrase()); } makeRoom(); } Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java?rev=1425175&r1=1425174&r2=1425175&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java Fri Dec 21 23:02:35 2012 @@ -91,7 +91,10 @@ public class WsRemoteEndpoint implements CharBuffer cb = CharBuffer.wrap(fragment); CoderResult cr = encoder.encode(cb, textToByte, true); while (cr.isOverflow()) { + textToByte.flip(); sendMessage(Constants.OPCODE_TEXT, textToByte, first, false); + textToByte.clear(); + cr = encoder.encode(cb, textToByte, true); first = false; } sendMessage(Constants.OPCODE_TEXT, textToByte, first, isLast); @@ -217,7 +220,6 @@ public class WsRemoteEndpoint implements } // If not the first fragment, it is a continuation with opCode of zero - message.flip(); header.put(first); // Next write the length --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org