use of com.webpieces.http2.api.dto.lowlevel.RstStreamFrame in project webpieces by deanhiller.
the class TestCancelStream method testClientCancelWithKeepAlive.
// @Test
// public void testRequestResponseXFutureCancelNoKeepAlive() {
// throw new UnsupportedOperationException("not done yet");
// }
//
// @Test
// public void testRequestResponseXFutureCancelWithKeepAlive() {
// throw new UnsupportedOperationException("not done yet");
// }
@Test
public void testClientCancelWithKeepAlive() {
XFuture<Void> connect = httpSocket.connect(new InetSocketAddress(8555));
MockResponseListener mockListener = new MockResponseListener();
Http2Request req = Requests.createRequest(false);
req.addHeader(new Http2Header(Http2HeaderName.CONNECTION, "keep-alive"));
mockChannel.addWriteResponse(XFuture.completedFuture(null));
RequestStreamHandle requestStream = httpSocket.openStream();
StreamRef ref = requestStream.process(req, mockListener);
CancelReason reason = new RstStreamFrame();
XFuture<Void> cancelDone = ref.cancel(reason);
Assert.assertTrue(cancelDone.isDone());
// Assert the socket is NOT closed
Assert.assertFalse(mockChannel.isClosed());
}
use of com.webpieces.http2.api.dto.lowlevel.RstStreamFrame in project webpieces by deanhiller.
the class TestCancelStream method testClientCancelNoKeepAlive.
@Test
public void testClientCancelNoKeepAlive() {
XFuture<Void> connect = httpSocket.connect(new InetSocketAddress(8555));
MockResponseListener mockListener = new MockResponseListener();
Http2Request req = Requests.createRequest(false);
mockChannel.addWriteResponse(XFuture.completedFuture(null));
RequestStreamHandle requestStream = httpSocket.openStream();
StreamRef ref = requestStream.process(req, mockListener);
CancelReason reason = new RstStreamFrame();
XFuture<Void> cancelDone = ref.cancel(reason);
Assert.assertTrue(cancelDone.isDone());
// Assert the socket is NOT closed
Assert.assertTrue(mockChannel.isClosed());
}
use of com.webpieces.http2.api.dto.lowlevel.RstStreamFrame in project webpieces by deanhiller.
the class RstStreamMarshaller method unmarshal.
@Override
public AbstractHttp2Frame unmarshal(Http2MementoImpl state, DataWrapper framePayloadData) {
FrameHeaderData frameHeaderData = state.getFrameHeaderData();
int streamId = frameHeaderData.getStreamId();
if (state.getFrameHeaderData().getPayloadLength() != 4)
throw new ConnectionException(CancelReasonCode.FRAME_SIZE_INCORRECT, streamId, "rststream size not 4 and instead is=" + state.getFrameHeaderData().getPayloadLength());
else if (frameHeaderData.getStreamId() == 0)
throw new ConnectionException(CancelReasonCode.INVALID_STREAM_ID, frameHeaderData.getStreamId(), "rst stream cannot be streamid 0 and was=" + frameHeaderData.getStreamId());
RstStreamFrame frame = new RstStreamFrame();
super.unmarshalFrame(state, frame);
ByteBuffer payloadByteBuffer = bufferPool.createWithDataWrapper(framePayloadData);
long errorCode = UnsignedData.getUnsignedInt(payloadByteBuffer);
frame.setErrorCode(errorCode);
bufferPool.releaseBuffer(payloadByteBuffer);
return frame;
}
use of com.webpieces.http2.api.dto.lowlevel.RstStreamFrame in project webpieces by deanhiller.
the class RstStreamMarshaller method marshal.
@Override
public DataWrapper marshal(Http2Frame frame) {
RstStreamFrame castFrame = (RstStreamFrame) frame;
ByteBuffer payload = bufferPool.nextBuffer(4);
UnsignedData.putUnsignedInt(payload, castFrame.getErrorCode());
payload.flip();
DataWrapper dataPayload = DATA_GEN.wrapByteBuffer(payload);
return super.marshalFrame(frame, (byte) 0, dataPayload);
}
use of com.webpieces.http2.api.dto.lowlevel.RstStreamFrame in project webpieces by deanhiller.
the class TestHttp2RstStream method testParseRstStream.
@Test
public void testParseRstStream() {
DataWrapper data = Util.hexToBytes(connectError());
parser.parse(memento, data);
RstStreamFrame frame = (RstStreamFrame) assertGood();
Assert.assertEquals(4, frame.getStreamId());
Assert.assertEquals(10, frame.getErrorCode());
}
Aggregations