empty frames with no constructor will generate correctly
This commit is contained in:
parent
888314e08a
commit
a0516774c0
|
@ -36,7 +36,7 @@ public class BaseFrame
|
|||
private boolean rsv3 = false;
|
||||
private OpCode opcode = null;
|
||||
private boolean masked = false;
|
||||
private int payloadLength;
|
||||
private int payloadLength = 0;
|
||||
private byte mask[];
|
||||
private ByteBuffer payload = null;
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class BaseFrame
|
|||
rsv3 = false;
|
||||
opcode = null;
|
||||
masked = false;
|
||||
payloadLength = -1;
|
||||
payloadLength = 0;
|
||||
mask = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ public class PingFrame extends ControlFrame
|
|||
}
|
||||
|
||||
/**
|
||||
* Construct Ping Frame from known bytebuffer
|
||||
* Construct Ping Frame from known byte[]
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
public PingFrame(ByteBuffer payload)
|
||||
public PingFrame(byte[] payload)
|
||||
{
|
||||
this();
|
||||
setPayload(payload);
|
||||
|
|
|
@ -15,7 +15,10 @@ public class PingFrameGenerator extends FrameGenerator<PingFrame>
|
|||
|
||||
@Override
|
||||
public void fillPayload(ByteBuffer buffer, PingFrame ping)
|
||||
{
|
||||
if ( ping.hasPayload() )
|
||||
{
|
||||
BufferUtil.put(ping.getPayload(),buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package org.eclipse.jetty.websocket.ab;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.websocket.ByteBufferAssert;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.frames.PingFrame;
|
||||
import org.eclipse.jetty.websocket.generator.Generator;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ABCase2
|
||||
{
|
||||
@Test
|
||||
public void testGenerateEmptyPingCase2_1()
|
||||
{
|
||||
PingFrame pingFrame = new PingFrame();
|
||||
|
||||
WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER);
|
||||
|
||||
Generator generator = new Generator(policy);
|
||||
ByteBuffer actual = ByteBuffer.allocate(32);
|
||||
generator.generate(actual, pingFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89, (byte)0x00 });
|
||||
|
||||
actual.flip();
|
||||
expected.flip();
|
||||
|
||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue