Package org.apache.http

Examples of org.apache.http.HttpHost


        new UsernamePasswordCredentials( serverAdminUser, serverAdminPassword )
        );

    AuthCache authCache = new BasicAuthCache();
    authCache.put(
        new HttpHost( host, port, "http" ),
        new BasicScheme()
        );

    BasicHttpContext localContext = new BasicHttpContext();
    localContext.setAttribute( ClientContext.AUTH_CACHE, authCache );
View Full Code Here


      throws ExecutionException {
    try {
      final Request request = Request.Post("http://" + host + ":" + port)
          .socketTimeout(0).connectTimeout(0);
      if (proxyhost != null && proxyport != null) {
        request.viaProxy(new HttpHost(proxyhost, Integer.valueOf(proxyport)));
      }
      final HttpResponse response = request
          .addHeader(Version.HEADER, Version.getCurrentVersion().toString())
          .bodyByteArray(bytes).execute().returnResponse();
      return handleResponse(response);
View Full Code Here

        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
        request = new HttpGet(uri);
        if (!hostName.equals("localhost")) {
            request.getParams().setParameter(ClientPNames.VIRTUAL_HOST, new HttpHost(hostName, 8080));
        }

        executeHttpRequestAndRelay();
    }
View Full Code Here

            String serverName = extractServerNameFromUri(uri);
            uri = uri.replace(serverName, "localhost");
            HttpPost httpPost = new HttpPost(uri);
            if (!serverName.equals("localhost")) {
                httpPost.getParams().setParameter(ClientPNames.VIRTUAL_HOST, new HttpHost(serverName, 8080));
            }
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            formparams.add(new BasicNameValuePair(name, value));
            UrlEncodedFormEntity entity;
            try {
                entity = new UrlEncodedFormEntity(formparams, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
            httpPost.setEntity(entity);
            request = httpPost;
        } else if (responseType == ResponseType.SAML_MESSAGE_REDIRECT_BOUND) {
            String location = response.getFirstHeader("Location").getValue();
            log.info("Received redirect to " + location);
            String serverName = extractServerNameFromUri(location);
            HttpGet httpGet = new HttpGet(location.replace(serverName, "localhost"));
            httpGet.getParams().setParameter(ClientPNames.VIRTUAL_HOST, new HttpHost(serverName, 8080));
            request = httpGet;
        } else if (responseType == ResponseType.ERROR) {
            Assert.fail("Error response received by test client (status code " + response.getStatusLine().getStatusCode() + "): " + responseBody);
        } else {
            throw new RuntimeException("Cannot relay the non-SAML response type " + responseType + " (message: " + responseBody + ")");
View Full Code Here

            if (configuration.getHttpProxyUri() != null) {
                try {
                    final URIBuilder uriBuilder = new URIBuilder(configuration.getHttpProxyUri());
                    final URI proxyURI = uriBuilder.build();

                    configBuilder.setProxy(new HttpHost(proxyURI.getHost(), proxyURI.getPort(), proxyURI.getScheme()));
                } catch (Exception e) {
                    LOG.error("Invalid version check proxy URI: " + configuration.getHttpProxyUri(), e);
                    return;
                }
            }
View Full Code Here

            if (configuration.getHttpProxyUri() != null) {
                try {
                    final URIBuilder uriBuilder = new URIBuilder(configuration.getHttpProxyUri());
                    final URI proxyURI = uriBuilder.build();

                    configBuilder.setProxy(new HttpHost(proxyURI.getHost(), proxyURI.getPort(), proxyURI.getScheme()));
                } catch (Exception e) {
                    LOG.error("Invalid telemetry service proxy URI: {}", configuration.getHttpProxyUri(), e);
                    return;
                }
            }
View Full Code Here

            // apply simple configuration properties
            final RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
            requestConfigBuilder.setConnectTimeout(configuration.getConnectTimeout());
            requestConfigBuilder.setSocketTimeout(configuration.getSocketTimeout());

            final HttpHost proxy = configuration.getProxy();
            if (proxy != null) {
                requestConfigBuilder.setProxy(proxy);
            }

            // set default request config
View Full Code Here

        }

        // add HTTP proxy if set
        final Map<String, Object> httpParams = configuration.getHttpParams();
        if (httpParams != null && httpParams.get(ConnRoutePNames.DEFAULT_PROXY) != null) {
            final HttpHost proxyHost = (HttpHost) httpParams.get(ConnRoutePNames.DEFAULT_PROXY);
            final Boolean socksProxy = (Boolean) httpParams.get("http.route.socks-proxy");
            final ProxyConfig proxyConfig = new ProxyConfig(proxyHost.getHostName(), proxyHost.getPort(),
                socksProxy != null ? socksProxy : false);
            options.setProxyConfig(proxyConfig);
        }

        // authorize application on user's behalf
View Full Code Here

        options.setPrintContentOnFailingStatusCode(LOG.isDebugEnabled());
        options.setSSLClientProtocols(enabledProtocols);

        // add HTTP proxy if set
        if (httpParams != null && httpParams.get(ConnRoutePNames.DEFAULT_PROXY) != null) {
            final HttpHost proxyHost = (HttpHost) httpParams.get(ConnRoutePNames.DEFAULT_PROXY);
            final Boolean socksProxy = (Boolean) httpParams.get("http.route.socks-proxy");
            final ProxyConfig proxyConfig = new ProxyConfig(proxyHost.getHostName(), proxyHost.getPort(),
                socksProxy != null ? socksProxy : false);
            options.setProxyConfig(proxyConfig);
        }

        if (!lazyAuth) {
View Full Code Here

            }
            HttpCommandExecutor ce = (HttpCommandExecutor) d
                    .getCommandExecutor();
            String hostName = ce.getAddressOfRemoteServer().getHost();
            int port = ce.getAddressOfRemoteServer().getPort();
            HttpHost host = new HttpHost(hostName, port);
            DefaultHttpClient client = new DefaultHttpClient();
            URL sessionURL = new URL("http://" + hostName + ":" + port
                    + "/grid/api/testsession?session=" + d.getSessionId());
            BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest(
                    "POST", sessionURL.toExternalForm());
View Full Code Here

TOP

Related Classes of org.apache.http.HttpHost

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.