Examples of ApacheHttpClientConfig


Examples of org.apache.wink.client.ApacheHttpClientConfig

        log.debug("Opening w/username: {}", username);

        // Using Apache HttpClient here, as it appears the default wink client does not handle redirects properly, even when configured to do so
        HttpClient httpClient = new DefaultHttpClient();
        ClientConfig config = new ApacheHttpClientConfig(httpClient);
        config.followRedirects(true);

        config.handlers(
            new LoggingHandler(log, /*debug*/ false),
            new BasicAuthSecurityHandler(username, password)
        );

        this.client = new RestClient(config);
View Full Code Here

Examples of org.apache.wink.client.httpclient.ApacheHttpClientConfig

        EntityWriter entityWriter = null;
        if (request.getEntity() != null) {
            os = adaptOutputStream(ncos, request, context.getOutputStreamAdapters());
            // cast is safe because we're on the client
            ApacheHttpClientConfig config = (ApacheHttpClientConfig)request.getAttribute(WinkConfiguration.class);
            // prepare the entity that will write our entity
            entityWriter = new EntityWriter(this, request, os, ncos, config.isChunked());
        }

        HttpRequestBase entityRequest = setupHttpRequest(request, client, entityWriter);

        try {
View Full Code Here

Examples of org.apache.wink.client.httpclient.ApacheHttpClientConfig

        if (this.httpclient != null) {
            return this.httpclient;
        }

        // cast is safe because we're on the client
        ApacheHttpClientConfig config = (ApacheHttpClientConfig)request.getAttribute(WinkConfiguration.class);
        BasicHttpParams params = new BasicHttpParams();
        params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Integer.valueOf(config
            .getConnectTimeout()));
        params.setParameter(CoreConnectionPNames.SO_TIMEOUT, Integer.valueOf(config
            .getReadTimeout()));
        params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.valueOf(config
            .isFollowRedirects()));
        if (config.isFollowRedirects()) {
            params.setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, Boolean.TRUE);
        }
        // setup proxy
        if (config.getProxyHost() != null) {
            params.setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(config.getProxyHost(),
                                                                            config.getProxyPort()));
        }

        if (config.getMaxPooledConnections() > 0) {
            SchemeRegistry schemeRegistry = SchemeRegistryFactory.createDefault();
            ThreadSafeClientConnManager httpConnectionManager = new ThreadSafeClientConnManager(schemeRegistry);

            httpConnectionManager.setMaxTotal(config.getMaxPooledConnections());
            httpConnectionManager.setDefaultMaxPerRoute(config.getMaxPooledConnections());

            this.httpclient = new DefaultHttpClient(httpConnectionManager, params);
        } else {
            this.httpclient = new DefaultHttpClient(params);
        }

        if (config.getBypassHostnameVerification()) {
            SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(null, null, null);

            SSLSocketFactory sf = new SSLSocketFactory(sslcontext, new X509HostnameVerifier() {
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.