public static DefaultFullRequest.Builder newPost(String path) { return newPost().path(path); } }
@Test public void testFullRequestWithBody() throws Exception { outputReceived = new CountDownLatch(1); ByteBuf body = ByteBufUtil.writeUtf8(UnpooledByteBufAllocator.DEFAULT, "body"); FullRequest requestIn = RequestBuilders.newPost("/").host("localhost").body(body).build(); channel.writeOutbound(requestIn); channel.runPendingTasks(); // blocks Uninterruptibles.awaitUninterruptibly(outputReceived); Http2Request requestOut = (Http2Request) requests.remove(0); assertTrue(requestOut != null); assertTrue(requestOut.payload instanceof Http2Headers); assertEquals("POST", ((Http2Headers) requestOut.payload).method().toString()); assertEquals("/", ((Http2Headers) requestOut.payload).path()); assertFalse(requestOut.eos); Http2Request contentOut = (Http2Request) requests.remove(0); assertTrue(contentOut != null); assertTrue(contentOut.payload instanceof Http2DataFrame); assertEquals(body, ((Http2DataFrame) contentOut.payload).content()); assertTrue(contentOut.eos); }
@Test public void testFullRequestWithBody() throws Exception { outputReceived = new CountDownLatch(1); ByteBuf body = ByteBufUtil.writeUtf8(UnpooledByteBufAllocator.DEFAULT, "body"); FullRequest requestIn = RequestBuilders.newPost("/").body(body).build(); channel.writeOutbound(requestIn); channel.runPendingTasks(); // blocks Uninterruptibles.awaitUninterruptibly(outputReceived); FullHttpRequest requestOut = (FullHttpRequest) requests.remove(0); assertTrue(requestOut != null); assertEquals(HTTP_1_1, requestOut.protocolVersion()); assertEquals(HttpMethod.POST, requestOut.method()); assertEquals("/", requestOut.uri()); assertFalse(requestOut.content() == null); assertEquals(body, requestOut.content()); }