Package org.apache.http.params

Examples of org.apache.http.params.HttpParams


        this.localServer.register("/random/*", new RandomHandler());
        this.localServer.start();

        InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
       
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, "UTF-8");
        HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
        HttpProtocolParams.setUseExpectContinue(params, false);
        HttpConnectionParams.setStaleCheckingEnabled(params, false);
View Full Code Here


        mgr.shutdown();
    }
   
    public void testAbortAfterRequestStarts() throws Exception {
        HttpParams params = createDefaultParams();
        ConnManagerParams.setMaxTotalConnections(params, 1);

        ThreadSafeClientConnManager mgr = createTSCCM(params, null);

        HttpHost target = new HttpHost("www.test.invalid", 80, "http");
View Full Code Here

        mgr.shutdown();
    }
   
    public void testAbortBeforeRequestStarts() throws Exception {
        HttpParams params = createDefaultParams();
        ConnManagerParams.setMaxTotalConnections(params, 1);

        ThreadSafeClientConnManager mgr = createTSCCM(params, null);

        HttpHost target = new HttpHost("www.test.invalid", 80, "http");
View Full Code Here

        this.localServer.register("/random/*", new RandomHandler());
        this.localServer.start();

        InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
       
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, "UTF-8");
        HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
        HttpProtocolParams.setUseExpectContinue(params, false);
        HttpConnectionParams.setStaleCheckingEnabled(params, false);
View Full Code Here

        this.localServer.register("/random/*", new RandomHandler());
        this.localServer.start();

        InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
       
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, "UTF-8");
        HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
        HttpProtocolParams.setUseExpectContinue(params, false);
        HttpConnectionParams.setStaleCheckingEnabled(params, false);
View Full Code Here

            schreg = supportedSchemes;
        return new ThreadSafeClientConnManager(params, schreg);
    }

    public void testReleaseOnEntityConsumeContent() throws Exception {
        HttpParams params = defaultParams.copy();
        ConnManagerParams.setMaxTotalConnections
            (params, 1);
        ConnManagerParams.setMaxConnectionsPerRoute
            (params, new ConnPerRouteBean(1));
        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
View Full Code Here

       
        mgr.shutdown();
    }
   
    public void testReleaseOnEntityWriteTo() throws Exception {
        HttpParams params = defaultParams.copy();
        ConnManagerParams.setMaxTotalConnections
            (params, 1);
        ConnManagerParams.setMaxConnectionsPerRoute
            (params, new ConnPerRouteBean(1));
        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
View Full Code Here

       
        mgr.shutdown();
    }
   
    public void testReleaseOnAbort() throws Exception {
        HttpParams params = defaultParams.copy();
        ConnManagerParams.setMaxTotalConnections
            (params, 1);
        ConnManagerParams.setMaxConnectionsPerRoute
            (params, new ConnPerRouteBean(1));
        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
View Full Code Here

                response.setEntity(entity);
            }
           
        });
       
        HttpParams params = defaultParams.copy();
        ConnManagerParams.setMaxTotalConnections
            (params, 1);
        ConnManagerParams.setMaxConnectionsPerRoute
            (params, new ConnPerRouteBean(1));
        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
View Full Code Here

       
        HttpClient httpClient = map.get(key);

        if (httpClient == null){ // One-time init for this client

            HttpParams clientParams = new DefaultedHttpParams(new BasicHttpParams(), DEFAULT_HTTP_PARAMS);
           
            httpClient = new DefaultHttpClient(clientParams){
                @Override
                protected HttpRequestRetryHandler createHttpRequestRetryHandler() {
                    return new DefaultHttpRequestRetryHandler(RETRY_COUNT, false) {
                        // TODO HACK to fix https://issues.apache.org/jira/browse/HTTPCLIENT-1120
                        // can hopefully be removed when 4.1.3 or 4.2 are released
                        @Override
                        public boolean retryRequest(IOException ex, int count, HttpContext ctx) {
                            Object request = ctx.getAttribute(ExecutionContext.HTTP_REQUEST);
                            if(request instanceof HttpUriRequest){
                                if (request instanceof RequestWrapper) {
                                    request = ((RequestWrapper) request).getOriginal();
                                }
                                if(((HttpUriRequest)request).isAborted()){
                                    log.warn("Workround for HTTPCLIENT-1120 request retry: "+ex);
                                    return false;
                                }
                            }
                            /*
                             * When connect fails due to abort, the request is not in the context.
                             * Tried adding the request - with a new key - to the local context in the sample() method,
                             * but the request was not flagged as aborted, so that did not help.
                             * So we check for any specific exception that is triggered.
                             */
                            if (
                                   (ex instanceof java.net.BindException &&
                                    ex.getMessage().contains("Address already in use: connect"))   
                                ||
                                    ex.getMessage().contains("Request aborted") // plain IOException                               
                                ) {
                                /*
                                 * The above messages may be generated by aborted connects.
                                 * If either occurs in other situations, retrying is unlikely to help,
                                 * so preventing retry should not cause a problem.
                                */
                                log.warn("Workround for HTTPCLIENT-1120 connect retry: "+ex);
                                return false;
                            }
                            return super.retryRequest(ex, count, ctx);
                        } // end of hack
                    }; // set retry count
                }
            };
            ((AbstractHttpClient) httpClient).addResponseInterceptor(new ResponseContentEncoding());
            ((AbstractHttpClient) httpClient).addResponseInterceptor(METRICS_SAVER); // HACK
           
            // Override the defualt schemes as necessary
            SchemeRegistry schemeRegistry = httpClient.getConnectionManager().getSchemeRegistry();

            if (SLOW_HTTP != null){
                schemeRegistry.register(SLOW_HTTP);
            }

            if (HTTPS_SCHEME != null){
                schemeRegistry.register(HTTPS_SCHEME);
            }

            // Set up proxy details
            if (useDynamicProxy){
                HttpHost proxy = new HttpHost(proxyHost, proxyPort);
                clientParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
                String proxyUser = getProxyUser();
                if (proxyUser.length() > 0) {
                    ((AbstractHttpClient) httpClient).getCredentialsProvider().setCredentials(
                            new AuthScope(proxyHost, proxyPort),
                            new UsernamePasswordCredentials(proxyUser, getProxyPass()));
                }
            } else if (useStaticProxy) {
                HttpHost proxy = new HttpHost(PROXY_HOST, PROXY_PORT);
                clientParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
                if (PROXY_USER.length() > 0)
                    ((AbstractHttpClient) httpClient).getCredentialsProvider().setCredentials(
                            new AuthScope(PROXY_HOST, PROXY_PORT),
                            new UsernamePasswordCredentials(PROXY_USER, PROXY_PASS));
            }
View Full Code Here

TOP

Related Classes of org.apache.http.params.HttpParams

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.