Package org.apache.wink.client.httpclient

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


        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

Related Classes of org.apache.wink.client.httpclient.ApacheHttpClientConfig

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.