Examples of DefaultHttpClient


Examples of org.apache.http.impl.client.DefaultHttpClient

           
            SSLSocketFactory socketFactory = new SSLSocketFactory(sslcontext);
            socketFactory.setHostnameVerifier(hostnameVerifier);
           
            Scheme https = new Scheme("https", socketFactory, 443);
            DefaultHttpClient httpclient = new DefaultHttpClient();
            httpclient.getConnectionManager().getSchemeRegistry().register(https);
           
            HttpHost target = new HttpHost(
                    LocalTestServer.TEST_SERVER_ADDR.getHostName(),
                    server.getServicePort(),
                    "https");
            HttpGet httpget = new HttpGet("/random/100");
            HttpResponse response = httpclient.execute(target, httpget);
            assertEquals(200, response.getStatusLine().getStatusCode());
            assertTrue(hostnameVerifier.isFired());
        } finally {
            server.stop();
        }
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

    }

    public void testCircularRedirect() throws Exception {
        this.localServer.register("*", new CircularRedirectService());

        DefaultHttpClient client = new DefaultHttpClient();
        client.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, false);

        HttpGet httpget = new HttpGet("/circular-oldlocation/");

        try {
            client.execute(getServerHttp(), httpget);
            fail("ClientProtocolException exception should have been thrown");
        } catch (ClientProtocolException e) {
            assertTrue(e.getCause() instanceof CircularRedirectException);
        }
    }
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

    public void testPostRedirect() throws Exception {
        int port = this.localServer.getServicePort();
        String host = "localhost";
        this.localServer.register("*", new BasicRedirectService(host, port));

        DefaultHttpClient client = new DefaultHttpClient();
        HttpContext context = new BasicHttpContext();
       
        HttpPost httppost = new HttpPost("/oldlocation/");
        httppost.setEntity(new StringEntity("stuff"));

        HttpResponse response = client.execute(getServerHttp(), httppost, context);
        HttpEntity e = response.getEntity();
        if (e != null) {
            e.consumeContent();
        }
       
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

    public void testRelativeRedirect() throws Exception {
        int port = this.localServer.getServicePort();
        String host = this.localServer.getServiceHostName();
        this.localServer.register("*", new RelativeRedirectService());

        DefaultHttpClient client = new DefaultHttpClient();
        HttpContext context = new BasicHttpContext();

        client.getParams().setBooleanParameter(
                ClientPNames.REJECT_RELATIVE_REDIRECT, false);
        HttpGet httpget = new HttpGet("/oldlocation/");

        HttpResponse response = client.execute(getServerHttp(), httpget, context);
        HttpEntity e = response.getEntity();
        if (e != null) {
            e.consumeContent();
        }
       
View Full Code Here

Examples of org.vertx.java.core.http.impl.DefaultHttpClient

  public HttpServer createHttpServer() {
    return new DefaultHttpServer(this);
  }

  public HttpClient createHttpClient() {
    return new DefaultHttpClient(this);
  }
View Full Code Here

Examples of ratpack.http.client.internal.DefaultHttpClient

  private HttpClients() {
  }

  public static HttpClient httpClient(LaunchConfig launchConfig) {
    return new DefaultHttpClient(launchConfig.getExecController(), launchConfig.getBufferAllocator(), launchConfig.getMaxContentLength());
  }
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.