use of com.webpieces.http2parser.api.dto.CancelReason in project webpieces by deanhiller.
the class Level5AStates method translate.
protected Http2Event translate(Http2SendRecieve sendRecv, Http2Msg payload) {
Http2PayloadType payloadType;
if (payload instanceof Http2Headers) {
Http2Headers head = (Http2Headers) payload;
if (head.isEndOfStream())
payloadType = Http2PayloadType.HEADERS_EOS;
else
payloadType = Http2PayloadType.HEADERS;
} else if (payload instanceof DataFrame) {
DataFrame data = (DataFrame) payload;
if (data.isEndOfStream())
payloadType = Http2PayloadType.DATA_EOS;
else
payloadType = Http2PayloadType.DATA;
} else if (payload instanceof Http2Push) {
payloadType = Http2PayloadType.PUSH_PROMISE;
} else if (payload instanceof CancelReason) {
payloadType = Http2PayloadType.RESET_STREAM;
} else
throw new IllegalArgumentException("unknown payload type for payload=" + payload);
return Http2Event.lookup(sendRecv, payloadType);
}
use of com.webpieces.http2parser.api.dto.CancelReason in project webpieces by deanhiller.
the class TestC4FrameSizeAndHeaders method testSection4_3BadDecompression.
/**
* A decoding error in a header block MUST be treated as a connection error (Section 5.4.1) of type COMPRESSION_ERROR.
*
*/
@Test
public void testSection4_3BadDecompression() {
MockResponseListener listener1 = new MockResponseListener();
listener1.setIncomingRespDefault(CompletableFuture.<StreamWriter>completedFuture(null));
Http2Request request = sendRequestToServer(listener1);
//has to be 1 since we use 1 in the response
Assert.assertEquals(1, request.getStreamId());
String badHeaderFrame = // length
"00 00 10" + // type
"01" + // flags (ack)
"05" + // R + streamid
"00 00 00 01" + //payload
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
//endOfStream=false
mockChannel.writeHexBack(badHeaderFrame);
//remote receives goAway
GoAwayFrame goAway = (GoAwayFrame) mockChannel.getFrameAndClear();
Assert.assertEquals(Http2ErrorCode.COMPRESSION_ERROR, goAway.getKnownErrorCode());
DataWrapper debugData = goAway.getDebugData();
String msg = debugData.createStringFromUtf8(0, debugData.getReadableSize());
Assert.assertEquals("ConnectionException: MockHttp2Channel1:stream1:(HEADER_DECODE) Error from hpack library", msg);
Assert.assertTrue(mockChannel.isClosed());
List<CancelReason> results = listener1.getRstStreams();
Assert.assertEquals(1, results.size());
ShutdownStream failResp = (ShutdownStream) results.get(0);
Assert.assertEquals(CancelReasonCode.HEADER_DECODE, failResp.getCause().getReasonCode());
}
Aggregations