HttpServerRequestUtil { public static boolean isRequestHopsLimitExceeded(HttpServerRequest request, Integer hopsLimit){ if(hopsLimit == null){ return false; } Integer hops = HttpRequestHeader.getInteger(request.headers(), HttpRequestHeader.X_HOPS, 0); return hops > hopsLimit; } 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 testIsRequestHopsLimitExceeded(TestContext context){ IncreaseHopsRequest request = new IncreaseHopsRequest(new CaseInsensitiveHeaders()); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 0)); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 1)); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 20)); request = new IncreaseHopsRequest(new CaseInsensitiveHeaders().set(HttpRequestHeader.X_HOPS.getName(), "25")); context.assertTrue(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 0)); context.assertTrue(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 1)); context.assertTrue(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 15)); context.assertTrue(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 24)); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 25)); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 26)); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 50)); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, null)); request = new IncreaseHopsRequest(new CaseInsensitiveHeaders().set(HttpRequestHeader.X_HOPS.getName(), "booom")); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 0)); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 1)); context.assertFalse(HttpServerRequestUtil.isRequestHopsLimitExceeded(request, 10)); }