Package org.asynchttpclient

Examples of org.asynchttpclient.ProxyServer


        final int cTimeout = provider.getClientConfig().getConnectTimeout();
        final FutureImpl<Connection> future = Futures.createSafeFuture();
        final CompletionHandler<Connection> ch = Futures.toCompletionHandler(future,
                createConnectionCompletionHandler(request, requestFuture, null));
        final ProxyServer proxyServer = requestFuture.getProxyServer();
        final SocketAddress address = getRemoteAddress(request, proxyServer);

        ProxyAwareConnectorHandler handler = ProxyAwareConnectorHandler.builder(provider.clientTransport)
                .nonSecureFilterChainTemplate(nonSecureBuilder)//
                .secureFilterChainTemplate(secureBuilder)//
View Full Code Here


     * @param config the global config
     * @param request the request
     * @return the proxy server to be used for this request (can be null)
     */
    public static ProxyServer getProxyServer(AsyncHttpClientConfig config, Request request) {
        ProxyServer proxyServer = request.getProxyServer();
        if (proxyServer == null) {
            ProxyServerSelector selector = config.getProxyServerSelector();
            if (selector != null) {
                proxyServer = selector.select(request.getUri());
            }
View Full Code Here

                protocol = Protocol.valueOf(properties.getProperty(PROXY_PROTOCOL, "HTTP"));
            } catch (IllegalArgumentException e) {
                protocol = Protocol.HTTP;
            }

            ProxyServer proxyServer = new ProxyServer(protocol, host, port, properties.getProperty(PROXY_USER),
                    properties.getProperty(PROXY_PASSWORD));

            String nonProxyHosts = properties.getProperty(PROXY_NONPROXYHOSTS);
            if (nonProxyHosts != null) {
                for (String spec : nonProxyHosts.split("\\|")) {
                    proxyServer.addNonProxyHost(spec);
                }
            }

            return createProxyServerSelector(proxyServer);
        }
View Full Code Here

                                if (!(proxy.address() instanceof InetSocketAddress)) {
                                    log.warn("Don't know how to connect to address " + proxy.address());
                                    return null;
                                } else {
                                    InetSocketAddress address = (InetSocketAddress) proxy.address();
                                    return new ProxyServer(Protocol.HTTP, address.getHostName(), address.getPort());
                                }
                            case DIRECT:
                                return null;
                            default:
                                log.warn("ProxySelector returned proxy type that we don't know how to use: " + proxy.type());
View Full Code Here

        // FIXME really useful? Why not do this check when building the request?
        if (uri.getScheme().startsWith(WEBSOCKET) && !validateWebSocketRequest(request, asyncHandler))
            throw new IOException("WebSocket method must be a GET");

        ProxyServer proxyServer = getProxyServer(config, request);
        boolean resultOfAConnect = future != null && future.getNettyRequest() != null && future.getNettyRequest().getHttpRequest().getMethod() == HttpMethod.CONNECT;
        boolean useProxy = proxyServer != null && !resultOfAConnect;

        if (useProxy && useProxyConnect(uri))
            // SSL proxy, have to handle CONNECT
View Full Code Here

        if (clientTransport.isStopped()) {
            IOException e = new IOException("AsyncHttpClient has been closed.");
            handler.onThrowable(e);
            return new ListenableFuture.CompletedFailure<>(e);
        }
        final ProxyServer proxy = ProxyUtils.getProxyServer(clientConfig, request);
        final GrizzlyResponseFuture<T> future = new GrizzlyResponseFuture<T>(this, request, handler, proxy);
        future.setDelegate(SafeFutureImpl.<T> create());
        final CompletionHandler<Connection> connectHandler = new CompletionHandler<Connection>() {
            @Override
            public void cancelled() {
View Full Code Here

    }

    private boolean handleHttpResponse(final HttpResponse response, final Channel channel, final NettyResponseFuture<?> future, AsyncHandler<?> handler) throws Exception {

        HttpRequest httpRequest = future.getNettyRequest().getHttpRequest();
        ProxyServer proxyServer = future.getProxyServer();
        logger.debug("\n\nRequest {}\n\nResponse {}\n", httpRequest, response);

        // store the original headers so we can re-send all them to
        // the handler in case of trailing headers
        future.setHttpHeaders(response.headers());
View Full Code Here

        setUpServers(secure);

        String targetUrl = String.format("%s://127.0.0.1:%d/", secure ? "wss" : "ws", port2);

        // CONNECT happens over HTTP, not HTTPS
        ProxyServer ps = new ProxyServer(ProxyServer.Protocol.HTTP, "127.0.0.1", port1);
        AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder().setProxyServer(ps).setAcceptAnyCertificate(true).build();
        AsyncHttpClient asyncHttpClient = getAsyncHttpClient(config);
        try {
            final CountDownLatch latch = new CountDownLatch(1);
            final AtomicReference<String> text = new AtomicReference<String>("");
View Full Code Here

        Request req = new RequestBuilder("GET").setUrl("http://somewhere.com/foo").build();
        assertTrue(ProxyUtils.avoidProxy(null, req));

        // should avoid, it's in non-proxy hosts
        req = new RequestBuilder("GET").setUrl("http://somewhere.com/foo").build();
        ProxyServer proxyServer = new ProxyServer("foo", 1234);
        proxyServer.addNonProxyHost("somewhere.com");
        assertTrue(ProxyUtils.avoidProxy(proxyServer, req));

        // should avoid, it's in non-proxy hosts (with "*")
        req = new RequestBuilder("GET").setUrl("http://sub.somewhere.com/foo").build();
        proxyServer = new ProxyServer("foo", 1234);
        proxyServer.addNonProxyHost("*.somewhere.com");
        assertTrue(ProxyUtils.avoidProxy(proxyServer, req));

        // should use it
        req = new RequestBuilder("GET").setUrl("http://sub.somewhere.com/foo").build();
        proxyServer = new ProxyServer("foo", 1234);
        proxyServer.addNonProxyHost("*.somewhere.org");
        assertFalse(ProxyUtils.avoidProxy(proxyServer, req));
    }
View Full Code Here

TOP

Related Classes of org.asynchttpclient.ProxyServer

Copyright © 2018 www.massapicom. 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.