Package org.apache.http.nio.protocol

Examples of org.apache.http.nio.protocol.BasicAsyncRequestHandler


    }

    @Test
    public void testPostRedirectSeeOther() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(
                new BasicRedirectService(getSchemeName(), HttpStatus.SC_SEE_OTHER)));
        final HttpHost target = start(registry, null);

        final HttpClientContext context = HttpClientContext.create();

View Full Code Here


    }

    @Test
    public void testRelativeRedirect() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(new RelativeRedirectService()));
        final HttpHost target = start(registry, null);

        final HttpClientContext context = HttpClientContext.create();

        final RequestConfig config = RequestConfig.custom()
View Full Code Here

    }

    @Test
    public void testRelativeRedirect2() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(new RelativeRedirectService2()));
        final HttpHost target = start(registry, null);

        final HttpClientContext context = HttpClientContext.create();

        final RequestConfig config = RequestConfig.custom()
View Full Code Here

    }

    @Test(expected=ExecutionException.class)
    public void testRejectRelativeRedirect() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(new RelativeRedirectService()));
        final HttpHost target = start(registry, null);

        final RequestConfig config = RequestConfig.custom()
                .setRelativeRedirectsAllowed(false)
                .build();
View Full Code Here

    }

    @Test(expected=ExecutionException.class)
    public void testRejectBogusRedirectLocation() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(
                new BogusRedirectService(getSchemeName(), "xxx://bogus", true)));
        final HttpHost target = start(registry, null);

        final HttpGet httpget = new HttpGet("/oldlocation/");

View Full Code Here

    }

    @Test(expected=ExecutionException.class)
    public void testRejectInvalidRedirectLocation() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(
                new BogusRedirectService(getSchemeName(), "/newlocation/?p=I have spaces", false)));
        final HttpHost target = start(registry, null);

        final HttpGet httpget = new HttpGet("/oldlocation/");
        try {
View Full Code Here

    }

    @Test
    public void testRedirectWithCookie() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(
                new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));
        final HttpHost target = start(registry, null);

        final CookieStore cookieStore = new BasicCookieStore();
        final HttpClientContext context = HttpClientContext.create();
View Full Code Here

    }

    @Test
    public void testDefaultHeadersRedirect() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(
                new BasicRedirectService(getSchemeName(), HttpStatus.SC_MOVED_TEMPORARILY)));

        final List<Header> defaultHeaders = new ArrayList<Header>(1);
        defaultHeaders.add(new BasicHeader(HTTP.USER_AGENT, "my-test-client"));

View Full Code Here

    }

    @Test
    public void testCrossSiteRedirect() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("/random/*", new BasicAsyncRequestHandler(
                new RandomHandler()));
        final HttpHost redirectTarget = start(registry, null);

        final UriHttpAsyncRequestHandlerMapper registry2 = new UriHttpAsyncRequestHandlerMapper();
        registry2.register("/redirect/*", new BasicAsyncRequestHandler(
                new CrossSiteRedirectService(redirectTarget)));
        final HttpServerNio secondServer = new HttpServerNio(this.serverReactorConfig,
                createServerConnectionFactory(this.serverConnectionConfig));
        secondServer.setExceptionHandler(new SimpleIOReactorExceptionHandler());
        final HttpAsyncService serviceHandler = new HttpAsyncService(
View Full Code Here

    }

    @Test
    public void testBasicAuthenticationSuccess() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(new AuthHandler()));

        final BasicSchemeFactory myBasicAuthSchemeFactory = new BasicSchemeFactory() {

            @Override
            public AuthScheme create(final HttpContext context) {
View Full Code Here

TOP

Related Classes of org.apache.http.nio.protocol.BasicAsyncRequestHandler

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.