use of com.webpieces.http2.api.dto.lowlevel.CancelReason in project webpieces by deanhiller.
the class RequestStreamWriter2 method processPiece.
@Override
public XFuture<Void> processPiece(StreamMsg frame) {
if (cancelled) {
return XFuture.completedFuture(null);
} else if (frame instanceof CancelReason) {
cancelled = true;
responseFuture.cancel(true);
} else if (frame instanceof DataFrame) {
DataFrame dataFrame = (DataFrame) frame;
data = dataGen.chainDataWrappers(data, dataFrame.getData());
} else if (frame instanceof Http2Headers) {
if (!frame.isEndOfStream())
throw new IllegalArgumentException("Trailing headers from client must have end of stream set");
trailingHeaders = (Http2Headers) frame;
} else {
throw new IllegalStateException("frame not expected=" + frame);
}
if (frame.isEndOfStream()) {
return handleCompleteRequestImpl();
}
// return immediately resolved as we need more data to form request
return XFuture.completedFuture(null);
}
use of com.webpieces.http2.api.dto.lowlevel.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(XFuture.<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());
}
use of com.webpieces.http2.api.dto.lowlevel.CancelReason in project webpieces by deanhiller.
the class Level8NotifySvrListeners method sendRstToApp.
@Override
public XFuture<Void> sendRstToApp(Stream stream, CancelReason payload) {
if (stream instanceof ServerStream) {
ServerStream str = (ServerStream) stream;
StreamRef streamRef = str.getStreamRef();
return streamRef.cancel(payload);
}
// since the stream is closed, any writes to the push streams will automatically close and be cancelled
return XFuture.completedFuture(null);
}
use of com.webpieces.http2.api.dto.lowlevel.CancelReason in project webpieces by deanhiller.
the class Level8NotifyClntListeners method sendRstToApp.
@Override
public XFuture<Void> sendRstToApp(Stream stream, CancelReason payload) {
if (stream instanceof ClientStream) {
ClientStream str = (ClientStream) stream;
ResponseStreamHandle handler = str.getResponseListener();
return handler.cancel(payload);
}
ClientPushStream str = (ClientPushStream) stream;
PushStreamHandle handle = str.getPushStreamHandle();
return handle.cancelPush(payload);
}
Aggregations