tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1292601 - in /tomcat/trunk/java/org/apache/catalina/websocket: StreamInbound.java WsInputStream.java
Date Thu, 23 Feb 2012 00:41:23 GMT
Author: markt
Date: Thu Feb 23 00:41:22 2012
New Revision: 1292601

URL: http://svn.apache.org/viewvc?rev=1292601&view=rev
Log:
Handle ping frames in the middle of fragmented messages

Modified:
    tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java
    tomcat/trunk/java/org/apache/catalina/websocket/WsInputStream.java

Modified: tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java?rev=1292601&r1=1292600&r2=1292601&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java (original)
+++ tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java Thu Feb 23 00:41:22
2012
@@ -52,7 +52,7 @@ public abstract class StreamInbound impl
         // Must be start the start of a frame or series of frames
 
         try {
-            WsInputStream wsIs = new WsInputStream(processor);
+            WsInputStream wsIs = new WsInputStream(processor, outbound);
 
             WsFrame frame = wsIs.getFrame();
 

Modified: tomcat/trunk/java/org/apache/catalina/websocket/WsInputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/websocket/WsInputStream.java?rev=1292601&r1=1292600&r2=1292601&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/websocket/WsInputStream.java (original)
+++ tomcat/trunk/java/org/apache/catalina/websocket/WsInputStream.java Thu Feb 23 00:41:22
2012
@@ -29,13 +29,18 @@ import org.apache.coyote.http11.upgrade.
 public class WsInputStream extends java.io.InputStream {
 
     private UpgradeProcessor<?> processor;
-    private WsFrame frame;
+    private WsOutbound outbound;
 
+    private WsFrame frame;
     private long remaining;
     private long readThisFragment;
 
-    public WsInputStream(UpgradeProcessor<?> processor) throws IOException {
+    private String error = null;
+
+    public WsInputStream(UpgradeProcessor<?> processor, WsOutbound outbound)
+            throws IOException {
         this.processor = processor;
+        this.outbound = outbound;
         processFrame();
     }
 
@@ -54,13 +59,25 @@ public class WsInputStream extends java.
 
     @Override
     public int read() throws IOException {
+        if (error != null) {
+            throw new IOException(error);
+        }
         while (remaining == 0 && !getFrame().getFin()) {
             // Need more data - process next frame
             processFrame();
-
+            while (frame.isControl()) {
+                if (getFrame().getOpCode() == Constants.OPCODE_PING) {
+                    outbound.pong(frame.getPayLoad());
+                } else {
+                    // TODO
+                    throw new IOException("TODO");
+                }
+                processFrame();
+            }
             if (getFrame().getOpCode() != Constants.OPCODE_CONTINUATION) {
                 // TODO i18n
-                throw new IOException("Not a continuation frame");
+                error = "Not a continuation frame";
+                throw new IOException(error);
             }
         }
 



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


Mime
View raw message