servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/MalformedDataAfterHttpMessageTest.java
// malformed data at the end of the response msg
malformed data at the end of the response msg
malformed data at the end of the response msg
@Test
    void afterResponse() throws Exception {
        ServerSocketChannel server = nettyServer(RESPONSE_MSG);
        try (BlockingHttpClient client = stClient(server.localAddress())) {
            HttpRequest request = client.get("/1");
            ReservedBlockingHttpConnection connection = client.reserveConnection(request);
            CountDownLatch connectionClosedLatch = new CountDownLatch(1);
            connection.connectionContext().onClose().whenFinally(connectionClosedLatch::countDown).subscribe();
            validateClientResponse(connection.request(request));
            assertThat(assertThrows(Exception.class, () -> connection.request(connection.get("/2"))),
                    anyOf(instanceOf(DecoderException.class), instanceOf(ClosedChannelException.class)));
            connectionClosedLatch.await();
        } finally {
            server.close().sync();
        }
    }
@ Test void afterResponse ( ) throws Exception { ServerSocketChannel server = nettyServer ( RESPONSE_MSG ) ; try ( BlockingHttpClient client = stClient ( server . localAddress ( ) ) ) { HttpRequest request = client . get ( "/1" ) ; ReservedBlockingHttpConnection connection = client . reserveConnection ( request ) ; CountDownLatch connectionClosedLatch = new CountDownLatch ( 1 ) ; connection . connectionContext ( ) . onClose ( ) . whenFinally ( connectionClosedLatch :: countDown ) . subscribe ( ) ; validateClientResponse ( connection . request ( request ) ) ; assertThat ( assertThrows ( Exception . class , ( ) -> connection . request ( connection . get ( "/2" ) ) ) , anyOf ( instanceOf ( DecoderException . class ) , instanceOf ( ClosedChannelException . class ) ) ) ; connectionClosedLatch . await ( ) ; } finally { server . close ( ) . sync ( ) ; } }
malformed data at the end of the response msg
malformed data at the end of the response msg
// Verify that the next request fails and connection gets closed: // The exception generation is currently racy. A write maybe triggered while the channel is not active // which will lead to ClosedChannelException.