Package org.asynchttpclient

Examples of org.asynchttpclient.AsyncHttpClient.prepareGet()


    @Test(groups = { "standalone", "default_provider" })
    public void testRequestLevelProxy() throws IOException, ExecutionException, TimeoutException, InterruptedException {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            String target = "http://127.0.0.1:1234/";
            Future<Response> f = client.prepareGet(target).setProxyServer(new ProxyServer("127.0.0.1", port1)).execute();
            Response resp = f.get(3, TimeUnit.SECONDS);
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
            assertEquals(resp.getHeader("target"), "/");
        } finally {
View Full Code Here


    public void testGlobalProxy() throws IOException, ExecutionException, TimeoutException, InterruptedException {
        AsyncHttpClientConfig cfg = new AsyncHttpClientConfig.Builder().setProxyServer(new ProxyServer("127.0.0.1", port1)).build();
        AsyncHttpClient client = getAsyncHttpClient(cfg);
        try {
            String target = "http://127.0.0.1:1234/";
            Future<Response> f = client.prepareGet(target).execute();
            Response resp = f.get(3, TimeUnit.SECONDS);
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
            assertEquals(resp.getHeader("target"), "/");
        } finally {
View Full Code Here

    public void testBothProxies() throws IOException, ExecutionException, TimeoutException, InterruptedException {
        AsyncHttpClientConfig cfg = new AsyncHttpClientConfig.Builder().setProxyServer(new ProxyServer("127.0.0.1", port1 - 1)).build();
        AsyncHttpClient client = getAsyncHttpClient(cfg);
        try {
            String target = "http://127.0.0.1:1234/";
            Future<Response> f = client.prepareGet(target).setProxyServer(new ProxyServer("127.0.0.1", port1)).execute();
            Response resp = f.get(3, TimeUnit.SECONDS);
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
            assertEquals(resp.getHeader("target"), "/");
        } finally {
View Full Code Here

        AsyncHttpClientConfig cfg = new AsyncHttpClientConfig.Builder().setProxyServer(new ProxyServer("127.0.0.1", port1 - 1)).build();
        AsyncHttpClient client = getAsyncHttpClient(cfg);
        try {

            String target = "http://127.0.0.1:1234/";
            client.prepareGet(target).setProxyServer(new ProxyServer("127.0.0.1", port1).addNonProxyHost("127.0.0.1")).execute().get();
            assertFalse(true);
        } catch (Throwable e) {
            assertNotNull(e.getCause());
            assertEquals(e.getCause().getClass(), ConnectException.class);
        } finally {
View Full Code Here

    @Test(groups = { "standalone", "default_provider" })
    public void testNonProxyHostIssue202() throws IOException, ExecutionException, TimeoutException, InterruptedException {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            String target = "http://127.0.0.1:" + port1 + "/";
            Future<Response> f = client.prepareGet(target).setProxyServer(new ProxyServer("127.0.0.1", port1 - 1).addNonProxyHost("127.0.0.1")).execute();
            Response resp = f.get(3, TimeUnit.SECONDS);
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
            assertEquals(resp.getHeader("target"), "/");
        } finally {
View Full Code Here

            AsyncHttpClientConfig cfg = new AsyncHttpClientConfig.Builder().setUseProxyProperties(true).build();
            AsyncHttpClient client = getAsyncHttpClient(cfg);
            try {
                String target = "http://127.0.0.1:1234/";
                Future<Response> f = client.prepareGet(target).execute();
                Response resp = f.get(3, TimeUnit.SECONDS);
                assertNotNull(resp);
                assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
                assertEquals(resp.getHeader("target"), "/");
View Full Code Here

                assertNotNull(resp);
                assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
                assertEquals(resp.getHeader("target"), "/");

                target = "http://localhost:1234/";
                f = client.prepareGet(target).execute();
                try {
                    resp = f.get(3, TimeUnit.SECONDS);
                    fail("should not be able to connect");
                } catch (ExecutionException e) {
                    // ok, no proxy used
View Full Code Here

            System.setProperty("http.nonProxyHosts", "localhost");

            AsyncHttpClient client = getAsyncHttpClient(null);
            try {
                String target = "http://127.0.0.1:1234/";
                Future<Response> f = client.prepareGet(target).execute();
                try {
                    f.get(3, TimeUnit.SECONDS);
                    fail("should not be able to connect");
                } catch (ExecutionException e) {
                    // ok, no proxy used
View Full Code Here

            System.setProperty("org.asynchttpclient.AsyncHttpClientConfig.useProxyProperties", "true");

            AsyncHttpClient client = getAsyncHttpClient(null);
            try {
                String target = "http://127.0.0.1:1234/";
                Future<Response> f = client.prepareGet(target).execute();
                Response resp = f.get(3, TimeUnit.SECONDS);
                assertNotNull(resp);
                assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
                assertEquals(resp.getHeader("target"), "/");
View Full Code Here

                assertNotNull(resp);
                assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
                assertEquals(resp.getHeader("target"), "/");

                target = "http://localhost:1234/";
                f = client.prepareGet(target).execute();
                try {
                    resp = f.get(3, TimeUnit.SECONDS);
                    fail("should not be able to connect");
                } catch (ExecutionException e) {
                    // ok, no proxy used
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.