Package org.apache.http.client.config

Examples of org.apache.http.client.config.RequestConfig


            } else {
                execAware.setCancellable(connRequest);
            }
        }

        final RequestConfig config = context.getRequestConfig();

        HttpClientConnection managedConn;
        try {
            final int timeout = config.getConnectionRequestTimeout();
            managedConn = connRequest.get(timeout > 0 ? timeout : 0, TimeUnit.MILLISECONDS);
        } catch(final InterruptedException interrupted) {
            throw new RequestAbortedException("Request aborted", interrupted);
        }

        final ConnectionHolder releaseTrigger = new ConnectionHolder(log, connManager, managedConn);
        try {
            if (execAware != null) {
                if (execAware.isAborted()) {
                    releaseTrigger.abortConnection();
                    throw new RequestAbortedException("Request aborted");
                } else {
                    execAware.setCancellable(releaseTrigger);
                }
            }

            if (!managedConn.isOpen()) {
                final int timeout = config.getConnectTimeout();
                this.connManager.connect(
                    managedConn,
                    route.getTargetHost(), route.getLocalAddress(),
                    timeout > 0 ? timeout : 0,
                    context);
            } else {
                final int timeout = config.getSocketTimeout();
                if (timeout >= 0) {
                    managedConn.setSocketTimeout(timeout);
                }
            }
View Full Code Here


        };

        final TestCredentialsProvider credsProvider = new TestCredentialsProvider(
                new UsernamePasswordCredentials("test", "test"));

        final RequestConfig config = RequestConfig.custom()
            .setTargetPreferredAuthSchemes(Arrays.asList("MyBasic"))
            .build();
        final Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
            .register("MyBasic", myBasicAuthSchemeFactory)
            .build();
View Full Code Here

    }

    @Test
    public void testRequestExpectContinueHTTP10() throws Exception {
        final HttpContext context = new BasicHttpContext(null);
        final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
        context.setAttribute(ClientContext.REQUEST_CONFIG, config);
        final BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
                "POST", "/", HttpVersion.HTTP_1_0);
        final String s = "whatever";
        final StringEntity entity = new StringEntity(s, "US-ASCII");
View Full Code Here

    }

    @Test
    public void testRequestExpectContinueZeroContent() throws Exception {
        final HttpContext context = new BasicHttpContext(null);
        final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
        context.setAttribute(ClientContext.REQUEST_CONFIG, config);
        final BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        final String s = "";
        final StringEntity entity = new StringEntity(s, "US-ASCII");
        request.setEntity(entity);
View Full Code Here

public class TestRequestExpectContinue {

    @Test
    public void testRequestExpectContinueGenerated() throws Exception {
        final HttpContext context = new BasicHttpContext();
        final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
        context.setAttribute(ClientContext.REQUEST_CONFIG, config);
        final BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        final String s = "whatever";
        final StringEntity entity = new StringEntity(s, "US-ASCII");
        request.setEntity(entity);
View Full Code Here

    }

    @Test
    public void testRequestExpectContinueNotGenerated() throws Exception {
        final HttpContext context = new BasicHttpContext(null);
        final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(false).build();
        context.setAttribute(ClientContext.REQUEST_CONFIG, config);
        final BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        final String s = "whatever";
        final StringEntity entity = new StringEntity(s, "US-ASCII");
        request.setEntity(entity);
View Full Code Here

    @Test(expected=ClientProtocolException.class)
    public void testMaxRedirectCheck() throws Exception {
        final HttpHost target = getServerHttp();
        this.localServer.register("*", new CircularRedirectService());

        final RequestConfig config = RequestConfig.custom()
            .setCircularRedirectsAllowed(true)
            .setMaxRedirects(5)
            .build();

        final HttpGet httpget = new HttpGet("/circular-oldlocation/");
View Full Code Here

    @Test(expected=ClientProtocolException.class)
    public void testCircularRedirect() throws Exception {
        final HttpHost target = getServerHttp();
        this.localServer.register("*", new CircularRedirectService());

        final RequestConfig config = RequestConfig.custom()
            .setCircularRedirectsAllowed(false)
            .build();

        final HttpGet httpget = new HttpGet("/circular-oldlocation/");
        httpget.setConfig(config);
View Full Code Here

        final HttpHost target = getServerHttp();
        this.localServer.register("*", new RelativeRedirectService());

        final HttpContext context = new BasicHttpContext();

        final RequestConfig config = RequestConfig.custom().setRelativeRedirectsAllowed(true).build();
        final HttpGet httpget = new HttpGet("/oldlocation/");
        httpget.setConfig(config);

        final HttpResponse response = this.httpclient.execute(target, httpget, context);
        EntityUtils.consume(response.getEntity());
View Full Code Here

        final HttpHost target = getServerHttp();
        this.localServer.register("*", new RelativeRedirectService2());

        final HttpContext context = new BasicHttpContext();

        final RequestConfig config = RequestConfig.custom().setRelativeRedirectsAllowed(true).build();
        final HttpGet httpget = new HttpGet("/test/oldlocation");
        httpget.setConfig(config);

        final HttpResponse response = this.httpclient.execute(target, httpget, context);
        EntityUtils.consume(response.getEntity());
View Full Code Here

TOP

Related Classes of org.apache.http.client.config.RequestConfig

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.