WebSocket - Calling setPayload() outside of ContinuationFrame
This commit is contained in:
parent
e56fddfc4a
commit
4d9cb44536
|
@ -90,8 +90,8 @@ public class OnPartialTest
|
|||
{
|
||||
List<WebSocketFrame> frames = new ArrayList<>();
|
||||
frames.add(new TextFrame().setPayload("Saved").setFin(false));
|
||||
frames.add(new ContinuationFrame(" by ").setFin(false));
|
||||
frames.add(new ContinuationFrame("zero").setFin(true));
|
||||
frames.add(new ContinuationFrame().setPayload(" by ").setFin(false));
|
||||
frames.add(new ContinuationFrame().setPayload("zero").setFin(true));
|
||||
|
||||
PartialTrackingSocket socket = new PartialTrackingSocket();
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
|||
DataFrame frame = null;
|
||||
if (partialStarted)
|
||||
{
|
||||
frame = new ContinuationFrame(fragment);
|
||||
frame = new ContinuationFrame().setPayload(fragment);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
|||
DataFrame frame = null;
|
||||
if (partialStarted)
|
||||
{
|
||||
frame = new ContinuationFrame(fragment);
|
||||
frame = new ContinuationFrame().setPayload(fragment);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -30,21 +30,20 @@ public class ContinuationFrame extends DataFrame
|
|||
super(OpCode.CONTINUATION);
|
||||
}
|
||||
|
||||
public ContinuationFrame(byte[] buf)
|
||||
public ContinuationFrame setPayload(ByteBuffer buf)
|
||||
{
|
||||
this();
|
||||
setPayload(ByteBuffer.wrap(buf));
|
||||
super.setPayload(buf);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContinuationFrame(ByteBuffer buf)
|
||||
public ContinuationFrame setPayload(byte buf[])
|
||||
{
|
||||
this();
|
||||
setPayload(buf);
|
||||
return this.setPayload(ByteBuffer.wrap(buf));
|
||||
}
|
||||
|
||||
public ContinuationFrame(String payload)
|
||||
public ContinuationFrame setPayload(String message)
|
||||
{
|
||||
this(StringUtil.getBytes(payload));
|
||||
return this.setPayload(StringUtil.getUtf8Bytes(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,8 +47,8 @@ public class ParserTest
|
|||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("fragment1").setFin(false));
|
||||
send.add(new ContinuationFrame("fragment2").setFin(true));
|
||||
send.add(new ContinuationFrame("fragment3").setFin(false)); // bad frame
|
||||
send.add(new ContinuationFrame().setPayload("fragment2").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("fragment3").setFin(false)); // bad frame
|
||||
send.add(new TextFrame().setPayload("fragment4").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
|
@ -93,12 +93,12 @@ public class ParserTest
|
|||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("f1").setFin(false));
|
||||
send.add(new ContinuationFrame(",f2").setFin(false));
|
||||
send.add(new ContinuationFrame().setPayload(",f2").setFin(false));
|
||||
send.add(new PingFrame().setPayload("pong-1"));
|
||||
send.add(new ContinuationFrame(",f3").setFin(false));
|
||||
send.add(new ContinuationFrame(",f4").setFin(false));
|
||||
send.add(new ContinuationFrame().setPayload(",f3").setFin(false));
|
||||
send.add(new ContinuationFrame().setPayload(",f4").setFin(false));
|
||||
send.add(new PingFrame().setPayload("pong-2"));
|
||||
send.add(new ContinuationFrame(",f5").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload(",f5").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
ByteBuffer completeBuf = UnitGenerator.generate(send);
|
||||
|
|
|
@ -36,7 +36,7 @@ public class RFC6455ExamplesGeneratorTest
|
|||
public void testFragmentedUnmaskedTextMessage()
|
||||
{
|
||||
WebSocketFrame text1 = new TextFrame().setPayload("Hel").setFin(false);
|
||||
WebSocketFrame text2 = new ContinuationFrame("lo");
|
||||
WebSocketFrame text2 = new ContinuationFrame().setPayload("lo");
|
||||
|
||||
ByteBuffer actual1 = UnitGenerator.generate(text1);
|
||||
ByteBuffer actual2 = UnitGenerator.generate(text2);
|
||||
|
|
|
@ -165,11 +165,11 @@ public class FragmentExtensionTest
|
|||
// Expected Frames
|
||||
List<WebSocketFrame> expectedFrames = new ArrayList<>();
|
||||
expectedFrames.add(new TextFrame().setPayload("No amount of experim").setFin(false));
|
||||
expectedFrames.add(new ContinuationFrame("entation can ever pr").setFin(false));
|
||||
expectedFrames.add(new ContinuationFrame("ove me right;").setFin(true));
|
||||
expectedFrames.add(new ContinuationFrame().setPayload("entation can ever pr").setFin(false));
|
||||
expectedFrames.add(new ContinuationFrame().setPayload("ove me right;").setFin(true));
|
||||
|
||||
expectedFrames.add(new TextFrame().setPayload("a single experiment ").setFin(false));
|
||||
expectedFrames.add(new ContinuationFrame("can prove me wrong.").setFin(true));
|
||||
expectedFrames.add(new ContinuationFrame().setPayload("can prove me wrong.").setFin(true));
|
||||
|
||||
expectedFrames.add(new TextFrame().setPayload("-- Albert Einstein").setFin(true));
|
||||
|
||||
|
|
|
@ -107,11 +107,11 @@ public class WebSocketServletRFCTest
|
|||
|
||||
client.write(bin); // write buf1 (fin=false)
|
||||
|
||||
bin = new ContinuationFrame(buf2).setFin(false);
|
||||
bin = new ContinuationFrame().setPayload(buf2).setFin(false);
|
||||
|
||||
client.write(bin); // write buf2 (fin=false)
|
||||
|
||||
bin = new ContinuationFrame(buf3).setFin(true);
|
||||
bin = new ContinuationFrame().setPayload(buf3).setFin(true);
|
||||
|
||||
client.write(bin); // write buf3 (fin=true)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new PingFrame().setPayload("hello, ").setFin(false));
|
||||
send.add(new ContinuationFrame("world"));
|
||||
send.add(new ContinuationFrame().setPayload("world"));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -77,7 +77,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
public void testCase5_10() throws Exception
|
||||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new ContinuationFrame("sorry").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("sorry").setFin(true));
|
||||
send.add(new TextFrame().setPayload("hello, world"));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
public void testCase5_11() throws Exception
|
||||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new ContinuationFrame("sorry").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("sorry").setFin(true));
|
||||
send.add(new TextFrame().setPayload("hello, world"));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
public void testCase5_12() throws Exception
|
||||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new ContinuationFrame("sorry").setFin(false));
|
||||
send.add(new ContinuationFrame().setPayload("sorry").setFin(false));
|
||||
send.add(new TextFrame().setPayload("hello, world"));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
public void testCase5_13() throws Exception
|
||||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new ContinuationFrame("sorry").setFin(false));
|
||||
send.add(new ContinuationFrame().setPayload("sorry").setFin(false));
|
||||
send.add(new TextFrame().setPayload("hello, world"));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
|
@ -190,7 +190,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
public void testCase5_14() throws Exception
|
||||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new ContinuationFrame("sorry").setFin(false));
|
||||
send.add(new ContinuationFrame().setPayload("sorry").setFin(false));
|
||||
send.add(new TextFrame().setPayload("hello, world"));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
|
@ -220,8 +220,8 @@ public class TestABCase5 extends AbstractABCase
|
|||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("fragment1").setFin(false));
|
||||
send.add(new ContinuationFrame("fragment2").setFin(true));
|
||||
send.add(new ContinuationFrame("fragment3").setFin(false)); // bad frame
|
||||
send.add(new ContinuationFrame().setPayload("fragment2").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("fragment3").setFin(false)); // bad frame
|
||||
send.add(new TextFrame().setPayload("fragment4").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
|
@ -250,12 +250,12 @@ public class TestABCase5 extends AbstractABCase
|
|||
public void testCase5_16() throws Exception
|
||||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new ContinuationFrame("fragment1").setFin(false)); // bad frame
|
||||
send.add(new ContinuationFrame().setPayload("fragment1").setFin(false)); // bad frame
|
||||
send.add(new TextFrame().setPayload("fragment2").setFin(false));
|
||||
send.add(new ContinuationFrame("fragment3").setFin(true));
|
||||
send.add(new ContinuationFrame("fragment4").setFin(false)); // bad frame
|
||||
send.add(new ContinuationFrame().setPayload("fragment3").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("fragment4").setFin(false)); // bad frame
|
||||
send.add(new TextFrame().setPayload("fragment5").setFin(false));
|
||||
send.add(new ContinuationFrame("fragment6").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("fragment6").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -282,12 +282,12 @@ public class TestABCase5 extends AbstractABCase
|
|||
public void testCase5_17() throws Exception
|
||||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new ContinuationFrame("fragment1").setFin(true)); // nothing to continue
|
||||
send.add(new ContinuationFrame().setPayload("fragment1").setFin(true)); // nothing to continue
|
||||
send.add(new TextFrame().setPayload("fragment2").setFin(false));
|
||||
send.add(new ContinuationFrame("fragment3").setFin(true));
|
||||
send.add(new ContinuationFrame("fragment4").setFin(true)); // nothing to continue
|
||||
send.add(new ContinuationFrame().setPayload("fragment3").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("fragment4").setFin(true)); // nothing to continue
|
||||
send.add(new TextFrame().setPayload("fragment5").setFin(false));
|
||||
send.add(new ContinuationFrame("fragment6").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("fragment6").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -345,7 +345,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
// phase 1
|
||||
List<WebSocketFrame> send1 = new ArrayList<>();
|
||||
send1.add(new TextFrame().setPayload("f1").setFin(false));
|
||||
send1.add(new ContinuationFrame(",f2").setFin(false));
|
||||
send1.add(new ContinuationFrame().setPayload(",f2").setFin(false));
|
||||
send1.add(new PingFrame().setPayload("pong-1"));
|
||||
|
||||
List<WebSocketFrame> expect1 = new ArrayList<>();
|
||||
|
@ -353,10 +353,10 @@ public class TestABCase5 extends AbstractABCase
|
|||
|
||||
// phase 2
|
||||
List<WebSocketFrame> send2 = new ArrayList<>();
|
||||
send2.add(new ContinuationFrame(",f3").setFin(false));
|
||||
send2.add(new ContinuationFrame(",f4").setFin(false));
|
||||
send2.add(new ContinuationFrame().setPayload(",f3").setFin(false));
|
||||
send2.add(new ContinuationFrame().setPayload(",f4").setFin(false));
|
||||
send2.add(new PingFrame().setPayload("pong-2"));
|
||||
send2.add(new ContinuationFrame(",f5").setFin(true));
|
||||
send2.add(new ContinuationFrame().setPayload(",f5").setFin(true));
|
||||
send2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect2 = new ArrayList<>();
|
||||
|
@ -395,7 +395,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new PongFrame().setPayload("hello, ").setFin(false));
|
||||
send.add(new ContinuationFrame("world"));
|
||||
send.add(new ContinuationFrame().setPayload("world"));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -423,14 +423,14 @@ public class TestABCase5 extends AbstractABCase
|
|||
{
|
||||
List<WebSocketFrame> send1 = new ArrayList<>();
|
||||
send1.add(new TextFrame().setPayload("f1").setFin(false));
|
||||
send1.add(new ContinuationFrame(",f2").setFin(false));
|
||||
send1.add(new ContinuationFrame().setPayload(",f2").setFin(false));
|
||||
send1.add(new PingFrame().setPayload("pong-1"));
|
||||
|
||||
List<WebSocketFrame> send2 = new ArrayList<>();
|
||||
send2.add(new ContinuationFrame(",f3").setFin(false));
|
||||
send2.add(new ContinuationFrame(",f4").setFin(false));
|
||||
send2.add(new ContinuationFrame().setPayload(",f3").setFin(false));
|
||||
send2.add(new ContinuationFrame().setPayload(",f4").setFin(false));
|
||||
send2.add(new PingFrame().setPayload("pong-2"));
|
||||
send2.add(new ContinuationFrame(",f5").setFin(true));
|
||||
send2.add(new ContinuationFrame().setPayload(",f5").setFin(true));
|
||||
send2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect1 = new ArrayList<>();
|
||||
|
@ -469,14 +469,14 @@ public class TestABCase5 extends AbstractABCase
|
|||
{
|
||||
List<WebSocketFrame> send1 = new ArrayList<>();
|
||||
send1.add(new TextFrame().setPayload("f1").setFin(false));
|
||||
send1.add(new ContinuationFrame(",f2").setFin(false));
|
||||
send1.add(new ContinuationFrame().setPayload(",f2").setFin(false));
|
||||
send1.add(new PingFrame().setPayload("pong-1"));
|
||||
|
||||
List<WebSocketFrame> send2 = new ArrayList<>();
|
||||
send2.add(new ContinuationFrame(",f3").setFin(false));
|
||||
send2.add(new ContinuationFrame(",f4").setFin(false));
|
||||
send2.add(new ContinuationFrame().setPayload(",f3").setFin(false));
|
||||
send2.add(new ContinuationFrame().setPayload(",f4").setFin(false));
|
||||
send2.add(new PingFrame().setPayload("pong-2"));
|
||||
send2.add(new ContinuationFrame(",f5").setFin(true));
|
||||
send2.add(new ContinuationFrame().setPayload(",f5").setFin(true));
|
||||
send2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect1 = new ArrayList<>();
|
||||
|
@ -516,7 +516,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||
send.add(new ContinuationFrame("world").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("world").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -545,7 +545,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||
send.add(new ContinuationFrame("world").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("world").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -574,7 +574,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||
send.add(new ContinuationFrame("world").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("world").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -605,7 +605,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||
send.add(new PingFrame().setPayload("ping"));
|
||||
send.add(new ContinuationFrame("world").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("world").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -636,7 +636,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||
send.add(new PingFrame().setPayload("ping"));
|
||||
send.add(new ContinuationFrame("world").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("world").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -667,7 +667,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||
send.add(new PingFrame().setPayload("ping"));
|
||||
send.add(new ContinuationFrame("world").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("world").setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
@ -698,7 +698,7 @@ public class TestABCase5 extends AbstractABCase
|
|||
{
|
||||
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new ContinuationFrame("sorry").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("sorry").setFin(true));
|
||||
send.add(new TextFrame().setPayload("hello, world"));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ public class TestABCase6 extends AbstractABCase
|
|||
{
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setFin(false));
|
||||
send.add(new ContinuationFrame("middle").setFin(false));
|
||||
send.add(new ContinuationFrame().setPayload("middle").setFin(false));
|
||||
send.add(new ContinuationFrame().setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class TestABCase6 extends AbstractABCase
|
|||
|
||||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload(b1).setFin(false));
|
||||
send.add(new ContinuationFrame(b2).setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload(b2).setFin(true));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
|
|
|
@ -169,7 +169,7 @@ public class TestABCase7 extends AbstractABCase
|
|||
List<WebSocketFrame> send = new ArrayList<>();
|
||||
send.add(new TextFrame().setPayload("an").setFin(false));
|
||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
send.add(new ContinuationFrame("ticipation").setFin(true));
|
||||
send.add(new ContinuationFrame().setPayload("ticipation").setFin(true));
|
||||
|
||||
List<WebSocketFrame> expect = new ArrayList<>();
|
||||
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||
|
|
Loading…
Reference in New Issue