@Override public boolean hasBody() { return request.hasBody(); }
@Test public void testFullRequest() throws Exception { outputReceived = new CountDownLatch(1); FullHttpRequest requestIn = new DefaultFullHttpRequest(HTTP_1_1, GET, "/"); channel.writeInbound(requestIn); channel.runPendingTasks(); // blocks Uninterruptibles.awaitUninterruptibly(outputReceived); Request requestOut = requests.remove(0); assertTrue(requestOut != null); assertTrue(requestOut instanceof FullRequest); assertEquals("HTTP/1.1", requestOut.version()); assertEquals(HttpMethod.GET, requestOut.method()); assertEquals("/", requestOut.path()); assertFalse(requestOut.hasBody()); assertFalse(requestOut.body() == null); assertEquals(0, requestOut.body().readableBytes()); }
@Test public void testFullRequest() throws Exception { outputReceived = new CountDownLatch(1); Http2Headers headers = new DefaultHttp2Headers().method("GET").path("/"); Http2Request requestIn = Http2Request.build(1, headers, true); channel.writeInbound(requestIn); channel.runPendingTasks(); // blocks Uninterruptibles.awaitUninterruptibly(outputReceived); Request requestOut = requests.remove(0); assertNotNull(requestOut); assertTrue(requestOut instanceof FullRequest); assertEquals("h2", requestOut.version()); assertEquals(HttpMethod.GET, requestOut.method()); assertEquals("/", requestOut.path()); assertFalse(requestOut.hasBody()); assertNotNull(requestOut.body()); assertEquals(0, requestOut.body().readableBytes()); assertEquals(1, requestOut.streamId()); }
@Test public void testFullRequestWithBody() throws Exception { outputReceived = new CountDownLatch(1); String payload = "body"; ByteBuf body = ByteBufUtil.writeUtf8(UnpooledByteBufAllocator.DEFAULT, payload); FullHttpRequest requestIn = new DefaultFullHttpRequest(HTTP_1_1, GET, "/", body); channel.writeInbound(requestIn); channel.runPendingTasks(); // blocks Uninterruptibles.awaitUninterruptibly(outputReceived); Request requestOut = requests.remove(0); assertTrue(requestOut != null); assertTrue(requestOut instanceof FullRequest); assertEquals("HTTP/1.1", requestOut.version()); assertEquals(HttpMethod.GET, requestOut.method()); assertEquals("/", requestOut.path()); assertTrue(requestOut.hasBody()); assertFalse(requestOut.body() == null); assertEquals(body, requestOut.body()); }
assertEquals(HttpMethod.GET, requestOut.method()); assertEquals("/", requestOut.path()); assertFalse(requestOut.hasBody()); assertFalse(requestOut.body() == null); assertEquals(0, requestOut.body().readableBytes()); assertEquals(HttpMethod.GET, bodyOut1.method()); assertEquals("/", bodyOut1.path()); assertFalse(bodyOut1.hasBody()); assertFalse(bodyOut1.body() == null); assertFalse(((SegmentedRequestData) bodyOut1).content() == null); assertEquals(HttpMethod.GET, bodyOut2.method()); assertEquals("/", bodyOut2.path()); assertFalse(bodyOut2.hasBody()); assertFalse(bodyOut2.body() == null); assertFalse(((SegmentedRequestData) bodyOut2).content() == null);
assertEquals(HttpMethod.POST, requestOut.method()); assertEquals("/", requestOut.path()); assertFalse(requestOut.hasBody()); assertNotNull(requestOut.body()); assertEquals(0, requestOut.body().readableBytes()); assertEquals(HttpMethod.POST, bodyOut1.method()); assertEquals("/", bodyOut1.path()); assertFalse(bodyOut1.hasBody()); assertNotNull(bodyOut1.body()); assertNotNull(((SegmentedRequestData) bodyOut1).content()); assertEquals(HttpMethod.POST, bodyOut2.method()); assertEquals("/", bodyOut2.path()); assertFalse(bodyOut2.hasBody()); assertNotNull(bodyOut2.body()); assertNotNull(((SegmentedRequestData) bodyOut2).content());
assertEquals(HttpMethod.POST, requestOut.method()); assertEquals("/", requestOut.path()); assertFalse(requestOut.hasBody()); assertNotNull(requestOut.body()); assertEquals(0, requestOut.body().readableBytes()); assertEquals(HttpMethod.POST, bodyOut1.method()); assertEquals("/", bodyOut1.path()); assertFalse(bodyOut1.hasBody()); assertNotNull(bodyOut1.body()); assertNotNull(((SegmentedRequestData) bodyOut1).content()); assertEquals(HttpMethod.POST, bodyOut2.method()); assertEquals("/", bodyOut2.path()); assertFalse(bodyOut2.hasBody()); assertNotNull(bodyOut2.body()); assertNotNull(((SegmentedRequestData) bodyOut2).content()); assertEquals(HttpMethod.POST, trailersOut.method()); assertEquals("/", trailersOut.path()); assertFalse(trailersOut.hasBody()); assertNotNull(trailersOut.body()); assertEquals(0, trailersOut.body().readableBytes());