HttpServerRequestUtil { public static void increaseRequestHops(HttpServerRequest request){ Integer hops = HttpRequestHeader.getInteger(request.headers(), HttpRequestHeader.X_HOPS, 0); hops = hops + 1; request.headers().set(HttpRequestHeader.X_HOPS.getName(), String.valueOf(hops)); } private  HttpServerRequestUtil(); static boolean isRemoteAddressLoopbackAddress(HttpServerRequest request); static void increaseRequestHops(HttpServerRequest request); static boolean isRequestHopsLimitExceeded(HttpServerRequest request, Integer hopsLimit); static void prepareResponse(HttpServerRequest request, HttpClientResponse response);  }
@Test public void testIncreaseRequestHops(TestContext context){ IncreaseHopsRequest request = new IncreaseHopsRequest(new CaseInsensitiveHeaders()); context.assertFalse(HttpRequestHeader.containsHeader(request.headers(), HttpRequestHeader.X_HOPS), "x-hops header should not be present yet"); HttpServerRequestUtil.increaseRequestHops(request); context.assertTrue(HttpRequestHeader.containsHeader(request.headers(), HttpRequestHeader.X_HOPS), "x-hops header should be present"); context.assertEquals(1, HttpRequestHeader.getInteger(request.headers(), HttpRequestHeader.X_HOPS)); HttpServerRequestUtil.increaseRequestHops(request); context.assertEquals(2, HttpRequestHeader.getInteger(request.headers(), HttpRequestHeader.X_HOPS)); for (int i = 0; i < 500; i++) { HttpServerRequestUtil.increaseRequestHops(request); } context.assertEquals(502, HttpRequestHeader.getInteger(request.headers(), HttpRequestHeader.X_HOPS)); }