@Test(enabled = false) public void httpToHttpsRedirect() throws Exception { redirectDone.getAndSet(false); AsyncHttpClientConfig cg = config() .setMaxRedirects(5) .setFollowRedirect(true) .setUseInsecureTrustManager(true) .build(); try (AsyncHttpClient c = asyncHttpClient(cg)) { Response response = c.prepareGet(getTargetUrl()).setHeader("X-redirect", getTargetUrl2()).execute().get(); assertNotNull(response); assertEquals(response.getStatusCode(), 200); assertEquals(response.getHeader("X-httpToHttps"), "PASS"); } }
@Test public void nonPreemptiveProxyAuthWithHttpsTarget() throws IOException, InterruptedException, ExecutionException { try (AsyncHttpClient client = asyncHttpClient(config().setUseInsecureTrustManager(true))) { String targetUrl = "https://localhost:" + httpPort + "/foo/bar"; Request request = get(targetUrl) .setProxyServer(proxyServer("127.0.0.1", proxyPort).setRealm(realm(AuthScheme.BASIC, "johndoe", "pass"))) // .setRealm(realm(AuthScheme.BASIC, "user", "passwd")) .build(); Future<Response> responseFuture = client.executeRequest(request); Response response = responseFuture.get(); Assert.assertEquals(response.getStatusCode(), HttpServletResponse.SC_OK); Assert.assertEquals("/foo/bar", response.getHeader("X-pathInfo")); } } }
@Test(enabled = false) public void relativeLocationUrl() throws Exception { redirectDone.getAndSet(false); AsyncHttpClientConfig cg = config() .setMaxRedirects(5) .setFollowRedirect(true) .setUseInsecureTrustManager(true) .build(); try (AsyncHttpClient c = asyncHttpClient(cg)) { Response response = c.prepareGet(getTargetUrl()).setHeader("X-redirect", "/foo/test").execute().get(); assertNotNull(response); assertEquals(response.getStatusCode(), 200); assertEquals(response.getUri().toString(), getTargetUrl()); } }
confBuilder.setUseInsecureTrustManager(tlsAllowInsecureConnection); } catch (Exception e) { throw new PulsarClientException.InvalidConfigurationException(e);
confBuilder.setUseInsecureTrustManager(tlsAllowInsecureConnection); } catch (Exception e) { throw new PulsarClientException.InvalidConfigurationException(e);
try (AsyncHttpClient asyncHttpClient = asyncHttpClient(config().setProxyServer(ps).setUseInsecureTrustManager(true))) { final CountDownLatch latch = new CountDownLatch(1); final AtomicReference<String> text = new AtomicReference<>("");
@Test(enabled = false) public void httpToHttpsProperConfig() throws Exception { redirectDone.getAndSet(false); AsyncHttpClientConfig cg = config() .setMaxRedirects(5) .setFollowRedirect(true) .setUseInsecureTrustManager(true) .build(); try (AsyncHttpClient c = asyncHttpClient(cg)) { Response response = c.prepareGet(getTargetUrl()).setHeader("X-redirect", getTargetUrl2() + "/test2").execute().get(); assertNotNull(response); assertEquals(response.getStatusCode(), 200); assertEquals(response.getHeader("X-httpToHttps"), "PASS"); // Test if the internal channel is downgraded to clean http. response = c.prepareGet(getTargetUrl()).setHeader("X-redirect", getTargetUrl2() + "/foo2").execute().get(); assertNotNull(response); assertEquals(response.getStatusCode(), 200); assertEquals(response.getHeader("X-httpToHttps"), "PASS"); } }
@Test public void testDecompressBodyWithProxy() throws Exception { AsyncHttpClientConfig config = config() .setFollowRedirect(true) .setProxyServer(proxyServer("localhost", port1).build()) .setUseInsecureTrustManager(true) .build(); try (AsyncHttpClient asyncHttpClient = asyncHttpClient(config)) { String body = "hello world"; Response r = asyncHttpClient.executeRequest(post(getTargetUrl2()) .setHeader("X-COMPRESS", "true") .setBody(body)).get(); assertEquals(r.getStatusCode(), 200); assertEquals(r.getResponseBody(), body); } }
public Builder setAcceptAnyCertificate(boolean acceptAnyCertificate) { configBuilder.setUseInsecureTrustManager(acceptAnyCertificate); return this; }
@Test public void testPooledConnectionsWithProxy() throws Exception { try (AsyncHttpClient asyncHttpClient = asyncHttpClient(config().setFollowRedirect(true).setUseInsecureTrustManager(true).setKeepAlive(true))) { RequestBuilder rb = get(getTargetUrl2()).setProxyServer(proxyServer("localhost", port1)); Response r1 = asyncHttpClient.executeRequest(rb.build()).get(); assertEquals(r1.getStatusCode(), 200); Response r2 = asyncHttpClient.executeRequest(rb.build()).get(); assertEquals(r2.getStatusCode(), 200); } } }
@Test public void testConfigProxy() throws Exception { AsyncHttpClientConfig config = config() .setFollowRedirect(true) .setProxyServer(proxyServer("localhost", port1).build()) .setUseInsecureTrustManager(true) .build(); try (AsyncHttpClient asyncHttpClient = asyncHttpClient(config)) { Response r = asyncHttpClient.executeRequest(get(getTargetUrl2())).get(); assertEquals(r.getStatusCode(), 200); } }
@Test public void testNoDirectRequestBodyWithProxy() throws Exception { AsyncHttpClientConfig config = config() .setFollowRedirect(true) .setProxyServer(proxyServer("localhost", port1).build()) .setUseInsecureTrustManager(true) .build(); try (AsyncHttpClient asyncHttpClient = asyncHttpClient(config)) { Response r = asyncHttpClient.executeRequest(post(getTargetUrl2()).setBody(new ByteArrayBodyGenerator(LARGE_IMAGE_BYTES))).get(); assertEquals(r.getStatusCode(), 200); } }
@Test public void testRequestProxy() throws Exception { try (AsyncHttpClient asyncHttpClient = asyncHttpClient(config().setFollowRedirect(true).setUseInsecureTrustManager(true))) { RequestBuilder rb = get(getTargetUrl2()).setProxyServer(proxyServer("localhost", port1)); Response r = asyncHttpClient.executeRequest(rb.build()).get(); assertEquals(r.getStatusCode(), 200); } }