@Override public String version() { return request.version(); }
buf.append("===================================\r\n"); buf.append("VERSION: ").append(request.version()).append("\r\n"); buf.append("HOSTNAME: ").append(request.host("unknown")).append("\r\n"); buf.append("REQUEST_URI: ").append(request.path()).append("\r\n\r\n");
@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("HTTP/1.1", requestOut.version()); assertEquals(HttpMethod.GET, requestOut.method()); assertEquals("/", requestOut.path()); assertEquals("HTTP/1.1", bodyOut1.version()); assertEquals(HttpMethod.GET, bodyOut1.method()); assertEquals("/", bodyOut1.path()); assertEquals("HTTP/1.1", bodyOut2.version()); assertEquals(HttpMethod.GET, bodyOut2.method()); assertEquals("/", bodyOut2.path());
assertEquals("h2", requestOut.version()); assertEquals(HttpMethod.POST, requestOut.method()); assertEquals("/", requestOut.path()); assertEquals("h2", bodyOut1.version()); assertEquals(HttpMethod.POST, bodyOut1.method()); assertEquals("/", bodyOut1.path()); assertEquals("h2", bodyOut2.version()); assertEquals(HttpMethod.POST, bodyOut2.method()); assertEquals("/", bodyOut2.path());
assertEquals("h2", requestOut.version()); assertEquals(HttpMethod.POST, requestOut.method()); assertEquals("/", requestOut.path()); assertEquals("h2", bodyOut1.version()); assertEquals(HttpMethod.POST, bodyOut1.method()); assertEquals("/", bodyOut1.path()); assertEquals("h2", bodyOut2.version()); assertEquals(HttpMethod.POST, bodyOut2.method()); assertEquals("/", bodyOut2.path()); assertEquals("h2", trailersOut.version()); assertEquals(HttpMethod.POST, trailersOut.method()); assertEquals("/", trailersOut.path());