@Test(groups = "standalone") public void testNonProxyHostsRequestOverridesConfig() throws IOException, ExecutionException, TimeoutException, InterruptedException { ProxyServer configProxy = proxyServer("localhost", port1 - 1).build(); ProxyServer requestProxy = proxyServer("localhost", port1).setNonProxyHost("localhost").build(); try (AsyncHttpClient client = asyncHttpClient(config().setProxyServer(configProxy))) { String target = "http://localhost:1234/"; client.prepareGet(target).setProxyServer(requestProxy).execute().get(); assertFalse(true); } catch (Throwable e) { assertNotNull(e.getCause()); assertEquals(e.getCause().getClass(), ConnectException.class); } }
// @Test(groups = "standalone") public void redirected302InvalidTest() throws Exception { isSet.getAndSet(false); Exception e = null; try (AsyncHttpClient c = asyncHttpClient()) { c.preparePost(getTargetUrl()) .setFollowRedirect(true) .setHeader("X-redirect", String.format("http://localhost:%d/", port2)) .execute() .get(); } catch (ExecutionException ex) { e = ex; } assertNotNull(e); Throwable cause = e.getCause(); assertTrue(cause instanceof ConnectException); assertTrue(cause.getMessage().contains(":" + port2)); }
@Test(groups = "online", enabled = false) public void invalidStreamTest2() throws Exception { AsyncHttpClientConfig config = config() // .setRequestTimeout(10000) // .setFollowRedirect(true) // .setKeepAlive(false) // .setMaxRedirects(6) // .build(); try (AsyncHttpClient c = asyncHttpClient(config)) { Response response = c.prepareGet("http://bit.ly/aUjTtG").execute().get(); if (response != null) { System.out.println(response); } } catch (Throwable t) { t.printStackTrace(); assertNotNull(t.getCause()); assertEquals(t.getCause().getMessage(), "invalid version format: ICY"); } }