use of com.webpieces.http2.api.dto.highlevel.Http2Push in project webpieces by deanhiller.
the class TestC5x1StreamStates method sendPushFromServer.
private Http2Push sendPushFromServer(MockResponseListener listener1, Http2Request request) {
Http2Push resp1 = Requests.createPush(request.getStreamId());
mockChannel.write(resp1);
Http2Push response1 = listener1.getSinglePush();
Assert.assertEquals(resp1, response1);
return resp1;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Push in project webpieces by deanhiller.
the class TestC5x1StreamStates method testSection5_1BadFrameReceivedInReservedRemoteState.
/**
* Receiving any type of frame other than HEADERS, RST_STREAM, 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_1BadFrameReceivedInReservedRemoteState() {
MockPushListener pushListener = new MockPushListener();
pushListener.setIncomingRespDefault(XFuture.<Void>completedFuture(null));
MockResponseListener listener1 = new MockResponseListener();
listener1.setIncomingRespDefault(XFuture.<StreamWriter>completedFuture(null));
listener1.addReturnValuePush(pushListener);
Http2Request request = sendRequestToServer(listener1);
Http2Push push = sendPushFromServer(listener1, request);
DataFrame dataFrame = new DataFrame(push.getPromisedStreamId(), false);
mockChannel.write(dataFrame);
// 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: MockHttp2Channel1:stream2:(BAD_FRAME_RECEIVED_FOR_THIS_STATE) " + "No transition defined on statemachine for event=RECV_DATA when in state=Reserved(remote)", msg);
Assert.assertTrue(mockChannel.isClosed());
ShutdownStream failResp1 = (ShutdownStream) listener1.getSingleRstStream();
Assert.assertEquals(CancelReasonCode.BAD_FRAME_RECEIVED_FOR_THIS_STATE, failResp1.getCause().getReasonCode());
ShutdownStream failResp2 = (ShutdownStream) listener1.getSingleCancelPush();
Assert.assertEquals(CancelReasonCode.BAD_FRAME_RECEIVED_FOR_THIS_STATE, failResp2.getCause().getReasonCode());
}
use of com.webpieces.http2.api.dto.highlevel.Http2Push in project webpieces by deanhiller.
the class Http2Requests method createPush.
public static Http2Push createPush(int streamId) {
Http2Push push = new Http2Push();
push.setStreamId(streamId);
push.addHeader(new Http2Header(Http2HeaderName.SERVER, "me"));
return push;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Push in project webpieces by deanhiller.
the class HeaderEncoding method translateToFrames.
public List<Http2Frame> translateToFrames(long maxFrameSize, Encoder encoder, Http2Push p) {
PushPromiseFrame frame = new PushPromiseFrame();
frame.setStreamId(p.getStreamId());
frame.setPromisedStreamId(p.getPromisedStreamId());
List<Http2Header> headerList = p.getHeaders();
List<Http2Frame> headerFrames = toHeaderFrames(maxFrameSize, encoder, frame, headerList);
return headerFrames;
}
use of com.webpieces.http2.api.dto.highlevel.Http2Push in project webpieces by deanhiller.
the class TestS5x1StreamStates method testSection5_1BadFrameReceivedInReservedRemoteState.
/**
* reserved local
*
* A PRIORITY or WINDOW_UPDATE frame MAY be received in this state. Receiving any
* type of frame other than RST_STREAM, PRIORITY, or WINDOW_UPDATE 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_1BadFrameReceivedInReservedRemoteState() {
MockStreamWriter mockWriter = new MockStreamWriter();
XFuture<StreamWriter> futA = XFuture.completedFuture(mockWriter);
MockStreamRef mockStream = new MockStreamRef(futA);
mockListener.addMockStreamToReturn(mockStream);
Http2Request request = Http2Requests.createRequest(1, true);
mockChannel.send(request);
PassedIn in = mockListener.getSingleRequest();
ResponseStream stream = in.stream;
Http2Push push = Http2Requests.createPush(request.getStreamId());
stream.openPushStream().process(push);
Http2Msg pushMsg = mockChannel.getFrameAndClear();
Assert.assertEquals(push, pushMsg);
// send bad frame in this state
DataFrame data = Http2Requests.createData1(push.getPromisedStreamId(), false);
mockChannel.send(data);
Assert.assertTrue(mockStream.isCancelled());
// 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]:stream2:(BAD_FRAME_RECEIVED_FOR_THIS_STATE) " + "No transition defined on statemachine for event=RECV_DATA when in state=Reserved(local)", msg);
Assert.assertTrue(mockChannel.isClosed());
}
Aggregations