Package com.ning.http.client.AsyncHttpClientConfig

Examples of com.ning.http.client.AsyncHttpClientConfig.Builder


        String proxyPort = Play.configuration.getProperty("http.proxyPort", System.getProperty("http.proxyPort"));
        String proxyUser = Play.configuration.getProperty("http.proxyUser", System.getProperty("http.proxyUser"));
        String proxyPassword = Play.configuration.getProperty("http.proxyPassword", System.getProperty("http.proxyPassword"));
        String userAgent = Play.configuration.getProperty("http.userAgent");

        Builder confBuilder = new AsyncHttpClientConfig.Builder();
        if (proxyHost != null) {
            int proxyPortInt = 0;
            try {
                proxyPortInt = Integer.parseInt(proxyPort);
            } catch (NumberFormatException e) {
                Logger.error("Cannot parse the proxy port property '%s'. Check property http.proxyPort either in System configuration or in Play config file.", proxyPort);
                throw new IllegalStateException("WS proxy is misconfigured -- check the logs for details");
            }
            ProxyServer proxy = new ProxyServer(proxyHost, proxyPortInt, proxyUser, proxyPassword);
            confBuilder.setProxyServer(proxy);
        }
        if (userAgent != null) {
            confBuilder.setUserAgent(userAgent);
        }
        // when using raw urls, AHC does not encode the params in url.
        // this means we can/must encode it(with correct encoding) before passing it to AHC
        confBuilder.setUseRawUrl(true);
        httpClient = new AsyncHttpClient(confBuilder.build());
    }
View Full Code Here


        String proxyPort = Play.configuration.getProperty("http.proxyPort", System.getProperty("http.proxyPort"));
        String proxyUser = Play.configuration.getProperty("http.proxyUser", System.getProperty("http.proxyUser"));
        String proxyPassword = Play.configuration.getProperty("http.proxyPassword", System.getProperty("http.proxyPassword"));
        String userAgent = Play.configuration.getProperty("http.userAgent");

        Builder confBuilder = new AsyncHttpClientConfig.Builder();
        if (proxyHost != null) {
            int proxyPortInt = 0;
            try {
                proxyPortInt = Integer.parseInt(proxyPort);
            } catch (NumberFormatException e) {
                Logger.error("Cannot parse the proxy port property '%s'. Check property http.proxyPort either in System configuration or in Play config file.", proxyPort);
                throw new IllegalStateException("WS proxy is misconfigured -- check the logs for details");
            }
            ProxyServer proxy = new ProxyServer(proxyHost, proxyPortInt, proxyUser, proxyPassword);
            confBuilder.setProxyServer(proxy);
        }
        if (userAgent != null) {
            confBuilder.setUserAgent(userAgent);
        }
        // when using raw urls, AHC does not encode the params in url.
        // this means we can/must encode it(with correct encoding) before passing it to AHC
        confBuilder.setUseRawUrl(true);
        httpClient = new AsyncHttpClient(confBuilder.build());
    }
View Full Code Here

        String proxyPort = Play.configuration.getProperty("http.proxyPort", System.getProperty("http.proxyPort"));
        String proxyUser = Play.configuration.getProperty("http.proxyUser", System.getProperty("http.proxyUser"));
        String proxyPassword = Play.configuration.getProperty("http.proxyPassword", System.getProperty("http.proxyPassword"));
        String userAgent = Play.configuration.getProperty("http.userAgent");

        Builder confBuilder = new AsyncHttpClientConfig.Builder();
        if (proxyHost != null) {
            int proxyPortInt = 0;
            try {
                proxyPortInt = Integer.parseInt(proxyPort);
            } catch (NumberFormatException e) {
                Logger.error("Cannot parse the proxy port property '%s'. Check property http.proxyPort either in System configuration or in Play config file.", proxyPort);
                throw new IllegalStateException("WS proxy is misconfigured -- check the logs for details");
            }
            ProxyServer proxy = new ProxyServer(proxyHost, proxyPortInt, proxyUser, proxyPassword);
            confBuilder.setProxyServer(proxy);
        }
        if (userAgent != null) {
            confBuilder.setUserAgent(userAgent);
        }
        // when using raw urls, AHC does not encode the params in url.
        // this means we can/must encode it(with correct encoding) before passing it to AHC
        confBuilder.setUseRawUrl(true);
        httpClient = new AsyncHttpClient(confBuilder.build());
    }
View Full Code Here

    *
    * @return
    */
   protected AsyncHttpClient createClient(String principal, String password)
   {
      Builder builder = new AsyncHttpClientConfig.Builder();
      Realm realm = new Realm.RealmBuilder()
            .setPrincipal(System.getProperty("github.username"))
            .setPassword(System.getProperty("github.password"))
            .setUsePreemptiveAuth(true)
            .setScheme(AuthScheme.BASIC).build();
      builder.setRealm(realm);
      return new AsyncHttpClient(builder.build());
   }
View Full Code Here

        String proxyUser = Play.configuration.getProperty("http.proxyUser", System.getProperty("http.proxyUser"));
        String proxyPassword = Play.configuration.getProperty("http.proxyPassword", System.getProperty("http.proxyPassword"));
        String nonProxyHosts = Play.configuration.getProperty("http.nonProxyHosts", System.getProperty("http.nonProxyHosts"));
        String userAgent = Play.configuration.getProperty("http.userAgent");

        Builder confBuilder = new AsyncHttpClientConfig.Builder();
        if (proxyHost != null) {
            int proxyPortInt = 0;
            try {
                proxyPortInt = Integer.parseInt(proxyPort);
            } catch (NumberFormatException e) {
                Logger.error("Cannot parse the proxy port property '%s'. Check property http.proxyPort either in System configuration or in Play config file.", proxyPort);
                throw new IllegalStateException("WS proxy is misconfigured -- check the logs for details");
            }
            ProxyServer proxy = new ProxyServer(proxyHost, proxyPortInt, proxyUser, proxyPassword);
            if (nonProxyHosts != null) {
                final String[] strings = nonProxyHosts.split("\\|");
                for (String uril : strings) {
                    proxy.addNonProxyHost(uril);
                }
            }
            confBuilder.setProxyServer(proxy);
        }
        if (userAgent != null) {
            confBuilder.setUserAgent(userAgent);
        }
        // when using raw urls, AHC does not encode the params in url.
        // this means we can/must encode it(with correct encoding) before passing it to AHC
        confBuilder.setUseRawUrl(true);
        httpClient = new AsyncHttpClient(confBuilder.build());
    }
View Full Code Here

        String proxyUser = Yalp.configuration.getProperty("http.proxyUser", System.getProperty("http.proxyUser"));
        String proxyPassword = Yalp.configuration.getProperty("http.proxyPassword", System.getProperty("http.proxyPassword"));
        String nonProxyHosts = Yalp.configuration.getProperty("http.nonProxyHosts", System.getProperty("http.nonProxyHosts"));
        String userAgent = Yalp.configuration.getProperty("http.userAgent");

        Builder confBuilder = new AsyncHttpClientConfig.Builder();
        if (proxyHost != null) {
            int proxyPortInt = 0;
            try {
                proxyPortInt = Integer.parseInt(proxyPort);
            } catch (NumberFormatException e) {
                Logger.error("Cannot parse the proxy port property '%s'. Check property http.proxyPort either in System configuration or in Yalp config file.", proxyPort);
                throw new IllegalStateException("WS proxy is misconfigured -- check the logs for details");
            }
            ProxyServer proxy = new ProxyServer(proxyHost, proxyPortInt, proxyUser, proxyPassword);
            if (nonProxyHosts != null) {
                final String[] strings = nonProxyHosts.split("\\|");
                for (String uril : strings) {
                    proxy.addNonProxyHost(uril);
                }
            }
            confBuilder.setProxyServer(proxy);
        }
        if (userAgent != null) {
            confBuilder.setUserAgent(userAgent);
        }
        // when using raw urls, AHC does not encode the params in url.
        // this means we can/must encode it(with correct encoding) before passing it to AHC
        confBuilder.setUseRawUrl(true);
        httpClient = new AsyncHttpClient(confBuilder.build());
    }
View Full Code Here

    *
    * @return
    */
   protected AsyncHttpClient createClient(String principal, String password)
   {
      Builder builder = new AsyncHttpClientConfig.Builder();
      Realm realm = new Realm.RealmBuilder()
            .setPrincipal(System.getProperty("github.username"))
            .setPassword(System.getProperty("github.password"))
            .setUsePreemptiveAuth(true)
            .setScheme(AuthScheme.BASIC).build();
      builder.setRealm(realm);
      return new AsyncHttpClient(builder.build());
   }
View Full Code Here

      webSocket = null;
    }
  }
   
  private AsyncHttpClientConfig createAsyncHttpClientConfig() {
    Builder builder = new AsyncHttpClientConfig.Builder();
    builder.setRealm(createRealm());
    builder.setRequestTimeoutInMs(REQUEST_TIMEOUT_MS);
    return builder.build();
  }
View Full Code Here

TOP

Related Classes of com.ning.http.client.AsyncHttpClientConfig.Builder

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.