Fixing WebSocketAsyncConnection.write() of byte[] arrays

This commit is contained in:
Joakim Erdfelt 2012-07-10 14:45:37 -07:00
parent 4fd7ff76fb
commit 8aa6e5db9b
3 changed files with 3 additions and 4 deletions

View File

@ -4,7 +4,6 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.websocket.generator.Generator;
import org.eclipse.jetty.websocket.protocol.OpCode;
import org.eclipse.jetty.websocket.protocol.WebSocketFrame;
@ -34,8 +33,7 @@ public class ControlFrameBytes<C> extends FrameBytes<C>
{
if (buffer == null)
{
buffer = connection.getBufferPool().acquire(frame.getPayloadLength() + Generator.OVERHEAD,false);
connection.getGenerator().generate(frame);
buffer = connection.getGenerator().generate(frame);
BufferUtil.flipToFlush(buffer,0);
}
return buffer;

View File

@ -354,6 +354,7 @@ public class WebSocketFrame implements Frame
data = ByteBuffer.allocate(len);
BufferUtil.clearToFill(data);
data.put(buf,0,len);
BufferUtil.flipToFill(data);
return this;
}

View File

@ -160,7 +160,7 @@ public class WebSocketServletRFCTest
int ccCount = 0;
ByteBuffer echod = binmsg.getPayload();
while (echod.remaining() > 1)
while (echod.remaining() >= 1)
{
byte b = echod.get();
switch (b)