use of com.webpieces.http2engine.api.ConnectionClosedException in project webpieces by deanhiller.
the class TestC5_1StreamStates 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);
//endOfStream=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: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());
//send new request on closed connection
MockResponseListener listener1 = new MockResponseListener();
Http2Request request1 = Requests.createRequest();
CompletableFuture<StreamWriter> future = httpSocket.openStream().process(request1, listener1);
ConnectionClosedException intercept = (ConnectionClosedException) TestAssert.intercept(future);
Assert.assertTrue(intercept.getMessage().contains("Connection closed or closing"));
Assert.assertEquals(0, mockChannel.getFramesAndClear().size());
}
use of com.webpieces.http2engine.api.ConnectionClosedException in project webpieces by deanhiller.
the class Level4PreconditionChecks method createExcepted.
public CompletableFuture<Void> createExcepted(Http2Msg payload, String extra, ConnectionCancelled closedReason) {
log.info("returning CompletableFuture.exception since this socket is closed('" + extra + "' frame=" + payload + "):" + closedReason.getReasonCode());
CompletableFuture<Void> future = new CompletableFuture<>();
ConnectionClosedException exception = new ConnectionClosedException(closedReason, "Connection closed or closing:" + closedReason.getReasonCode());
if (closedReason instanceof ConnectionFailure) {
ConnectionFailure fail = (ConnectionFailure) closedReason;
exception.initCause(fail.getCause());
}
future.completeExceptionally(exception);
return future;
}
Aggregations