use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.
the class TestHttp2Data method testParseEndOfStreamTrue.
@Test
public void testParseEndOfStreamTrue() {
DataWrapper data = Util.hexToBytes(endStreamDataFrame());
parser.parse(memento, data);
DataFrame frame = (DataFrame) assertGood();
Assert.assertEquals(1, frame.getStreamId());
Assert.assertEquals(8, frame.getData().getReadableSize());
Assert.assertEquals(0, frame.getPadding().getReadableSize());
Assert.assertTrue(frame.isEndOfStream());
}
use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.
the class TestHttp2Data method testMarshalDataFrameUnpadded.
@Test
public void testMarshalDataFrameUnpadded() {
DataFrame frame = new DataFrame();
frame.setData(Util.hexToBytes("FF FF FF FF FF FF FF FF"));
frame.setStreamId(1);
byte[] data = parser.marshal(frame).createByteArray();
String hexFrame = Util.toHexString(data);
Assert.assertEquals(unpaddedDataFrame(), hexFrame);
}
use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.
the class TestHttp2Data method testMarshalDataFramePaddedEndStream.
@Test
public void testMarshalDataFramePaddedEndStream() {
DataFrame frame = new DataFrame();
frame.setData(Util.hexToBytes("FF FF FF FF FF FF FF FF"));
frame.setStreamId(1);
frame.setEndOfStream(true);
frame.setPadding(Util.hexToBytes("00 00"));
byte[] data = parser.marshal(frame).createByteArray();
String hexFrame = Util.toHexString(data);
Assert.assertEquals(paddedEndStreamDataFrame(), hexFrame);
}
use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.
the class ChunkedStream method writeDataOut.
private void writeDataOut() {
byte[] data = str.toByteArray();
str = new ByteArrayOutputStream();
DataWrapper body = wrapperFactory.wrapByteArray(data);
DataFrame frame = new DataFrame();
frame.setEndOfStream(false);
frame.setData(body);
cache.add(frame);
}
use of com.webpieces.http2.api.dto.lowlevel.DataFrame in project webpieces by deanhiller.
the class TestS5x1StreamStates method testSection5_1BadFrameReceivedInIdleState.
/**
* Receiving any frame other than HEADERS or PRIORITY on a stream in this state
* MUST be treated as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
*/
@Test
public void testSection5_1BadFrameReceivedInIdleState() {
DataFrame dataFrame = new DataFrame(1, false);
mockChannel.send(dataFrame);
// no request comes in
Assert.assertEquals(0, mockListener.getNumRequestsThatCameIn());
Assert.assertTrue(mockListener.isClosed());
// remote receives goAway
GoAwayFrame goAway = (GoAwayFrame) mockChannel.getFrameAndClear();
Assert.assertEquals(Http2ErrorCode.PROTOCOL_ERROR, goAway.getKnownErrorCode());
DataWrapper debugData = goAway.getDebugData();
String msg = debugData.createStringFromUtf8(0, debugData.getReadableSize());
Assert.assertEquals("ConnectionException: HttpSocket[Http2ChannelCache1]:stream1:(BAD_FRAME_RECEIVED_FOR_THIS_STATE) " + "Stream in idle state and received this frame which should not happen in idle state. " + "frame=DataFrame{streamId=1, endStream=false, data.len=0, padding=0}", msg);
Assert.assertTrue(mockChannel.isClosed());
}
Aggregations