Package org.apache.http

Examples of org.apache.http.HttpHost.toHostString()


    public void testAuthenticationUserinfoInRedirectSuccess() throws Exception {
        this.localServer.register("*", new AuthHandler());
        this.localServer.register("/thatway", new RedirectHandler());

        final HttpHost target = getServerHttp();
        final HttpGet httpget = new HttpGet("http://" +  target.toHostString() + "/thatway");

        this.httpclient = HttpClients.custom().build();

        final HttpResponse response = this.httpclient.execute(getServerHttp(), httpget);
        final HttpEntity entity = response.getEntity();
View Full Code Here


    @Test(expected=ClientProtocolException.class)
    public void testRejectInvalidRedirectLocation() throws Exception {
        final HttpHost target = getServerHttp();
        this.localServer.register("*",
                new BogusRedirectService("http://" + target.toHostString() +
                        "/newlocation/?p=I have spaces"));

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

        try {
View Full Code Here

                    } else {
                        throw new ProtocolException("Target host missing");
                    }
                }
            }
            request.addHeader(HTTP.TARGET_HOST, targethost.toHostString());
        }
    }

}
View Full Code Here

        this.serverBootstrap.setHandlerMapper(reqistry);

        final HttpHost target = start();

        reqistry.register("*",
                new BogusRedirectService("http://" + target.toHostString() +
                        "/newlocation/?p=I have spaces"));

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

        try {
View Full Code Here

    @Test
    public void testAuthenticationUserinfoInRequestSuccess() throws Exception {
        this.serverBootstrap.registerHandler("*", new AuthHandler());

        final HttpHost target = start();
        final HttpGet httpget = new HttpGet("http://test:test@" +  target.toHostString() + "/");

        final HttpClientContext context = HttpClientContext.create();
        final HttpResponse response = this.httpclient.execute(target, httpget, context);
        final HttpEntity entity = response.getEntity();
        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
View Full Code Here

    @Test
    public void testAuthenticationUserinfoInRequestFailure() throws Exception {
        this.serverBootstrap.registerHandler("*", new AuthHandler());

        final HttpHost target = start();
        final HttpGet httpget = new HttpGet("http://test:all-wrong@" +  target.toHostString() + "/");

        final HttpClientContext context = HttpClientContext.create();
        final HttpResponse response = this.httpclient.execute(target, httpget, context);
        final HttpEntity entity = response.getEntity();
        Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
View Full Code Here

        this.serverBootstrap.registerHandler("*", new AuthHandler());
        this.serverBootstrap.registerHandler("/thatway", new RedirectHandler());

        final HttpHost target = start();

        final HttpGet httpget = new HttpGet("http://" +  target.toHostString() + "/thatway");
        final HttpClientContext context = HttpClientContext.create();

        final HttpResponse response = this.httpclient.execute(target, httpget, context);
        final HttpEntity entity = response.getEntity();
        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
View Full Code Here

    public void testAuthenticationUserinfoInRequestSuccess() throws Exception {
        this.localServer.register("*", new AuthHandler());
        this.localServer.start();

        HttpHost target = getServerHttp();
        HttpGet httpget = new HttpGet("http://test:test@" +  target.toHostString() + "/");

        HttpResponse response = this.httpclient.execute(getServerHttp(), httpget);
        HttpEntity entity = response.getEntity();
        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
        Assert.assertNotNull(entity);
View Full Code Here

    public void testAuthenticationUserinfoInRequestFailure() throws Exception {
        this.localServer.register("*", new AuthHandler());
        this.localServer.start();

        HttpHost target = getServerHttp();
        HttpGet httpget = new HttpGet("http://test:all-wrong@" +  target.toHostString() + "/");

        HttpResponse response = this.httpclient.execute(getServerHttp(), httpget);
        HttpEntity entity = response.getEntity();
        Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
        Assert.assertNotNull(entity);
View Full Code Here

                    throw new AuthenticationException("Authentication host is not set " +
                            "in the execution context");
                }
                String authServer;
                if (!this.stripPort && host.getPort() > 0) {
                    authServer = host.toHostString();
                } else {
                    authServer = host.getHostName();
                }

                if (log.isDebugEnabled()) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.