Package org.apache.http.client

Examples of org.apache.http.client.URICollection


        final HttpRequest reqWrapper = context.getRequest();

        Assert.assertEquals(HttpStatus.SC_MULTIPLE_CHOICES, response.getStatusLine().getStatusCode());
        Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());

        URICollection redirects = context.getRedirectLocations();
        Assert.assertNull(redirects);
    }
View Full Code Here


        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
        Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
        Assert.assertEquals(target, host);

        URICollection redirects = context.getRedirectLocations();
        Assert.assertNotNull(redirects);
        Assert.assertEquals(1, redirects.getCount());

        URI redirect = URIUtils.rewriteURI(new URI("/newlocation/"), target);
        Assert.assertTrue(redirects.contains(redirect));
    }
View Full Code Here

            final HttpExecutionAware execAware) throws IOException, HttpException {
        Args.notNull(route, "HTTP route");
        Args.notNull(request, "HTTP request");
        Args.notNull(context, "HTTP context");

        final URICollection redirectLocations = context.getRedirectLocations();
        if (redirectLocations != null) {
            redirectLocations.clear();
        }

        final RequestConfig config = context.getRequestConfig();
        final int maxRedirects = config.getMaxRedirects() > 0 ? config.getMaxRedirects() : 50;
        HttpRoute currentRoute = route;
View Full Code Here

        response3.addHeader("Location", uri3.toASCIIString());
        Assert.assertEquals(uri1, redirectStrategy.getLocationURI(httpget1, response1, context));
        Assert.assertEquals(uri2, redirectStrategy.getLocationURI(httpget2, response2, context));
        Assert.assertEquals(uri3, redirectStrategy.getLocationURI(httpget3, response3, context));

        final URICollection redirectLocations = context.getRedirectLocations();
        Assert.assertNotNull(redirectLocations);
        Assert.assertTrue(redirectLocations.contains(uri1));
        Assert.assertTrue(redirectLocations.contains(uri2));
        Assert.assertTrue(redirectLocations.contains(uri3));
        final List<URI> uris = redirectLocations.getAll();
        Assert.assertNotNull(uris);
        Assert.assertEquals(3, uris.size());
        Assert.assertEquals(uri1, uris.get(0));
        Assert.assertEquals(uri2, uris.get(1));
        Assert.assertEquals(uri3, uris.get(2));
View Full Code Here

        EntityUtils.consume(response.getEntity());

        final HttpRequest request = context.getRequest();
        Assert.assertEquals("/stuff", request.getRequestLine().getUri());

        final URICollection redirectLocations = context.getRedirectLocations();
        final URI location = URIUtils.resolve(uri, target,
                redirectLocations != null ? redirectLocations.getAll() : null);
        Assert.assertEquals(uri, location);
    }
View Full Code Here

TOP

Related Classes of org.apache.http.client.URICollection

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.