tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1618835 - /tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
Date Tue, 19 Aug 2014 10:52:44 GMT
Author: markt
Date: Tue Aug 19 10:52:44 2014
New Revision: 1618835

URL: http://svn.apache.org/r1618835
Log:
Add plumbing to write reserved bits as set in the MessagePart rather
than hard-coding them to 0.
Re-order method parameters for writing header to align with RFC 6455.

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java?rev=1618835&r1=1618834&r2=1618835&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java Tue Aug 19
10:52:44 2014
@@ -390,8 +390,8 @@ public abstract class WsRemoteEndpointIm
         }
 
         headerBuffer.clear();
-        writeHeader(headerBuffer, mp.getOpCode(), mp.getPayload(), first,
-                mp.isFin(), isMasked(), mask);
+        writeHeader(headerBuffer, mp.isFin(), mp.getRsv(), mp.getOpCode(),
+                isMasked(), mp.getPayload(), mask, first);
         headerBuffer.flip();
 
         if (getBatchingAllowed() || isMasked()) {
@@ -549,20 +549,22 @@ public abstract class WsRemoteEndpointIm
     protected abstract boolean isMasked();
     protected abstract void doClose();
 
-    private static void writeHeader(ByteBuffer headerBuffer, byte opCode,
-            ByteBuffer payload, boolean first, boolean last, boolean masked,
-            byte[] mask) {
+    private static void writeHeader(ByteBuffer headerBuffer, boolean fin,
+            int rsv, byte opCode, boolean masked, ByteBuffer payload,
+            byte[] mask, boolean first) {
 
         byte b = 0;
 
-        if (last) {
+        if (fin) {
             // Set the fin bit
-            b = -128;
+            b -= 128;
         }
 
+        b += (rsv << 4);
+
         if (first) {
             // This is the first fragment of this message
-            b = (byte) (b + opCode);
+            b += opCode;
         }
         // If not the first fragment, it is a continuation with opCode of zero
 



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


Mime
View raw message