Package com.sun.jersey.client.apache4

Provides support for the Client API that utilizes the Apache HTTP client to send and receive HTTP request and responses.

See: Description

Package com.sun.jersey.client.apache4 Description

Provides support for the Client API that utilizes the Apache HTTP client to send and receive HTTP request and responses.

The client API with the Apache HTTP client can be used as follows to make simple GET and POST requests to a Web resource:

     Client c = ApacheHttpClient4.create();
     WebResource r = c.resource("http://host/base");
     String s = r.get(String.class);
     s = r.post(String.class, s);
 

To support basic authentication with the user name "foo" and the password "bar" the following configuration may be utilized:

 CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
 credentialsProvider.setCredentials(
         AuthScope.ANY,
         new UsernamePasswordCredentials("foo", "bar")
 );

 DefaultApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
 config.getProperties().put(
         ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER,
         credentialsProvider
 );
 Client c = ApacheHttpClient4.create(config);
 WebResource r = c.resource("http://host/base");
 String s = r.get(String.class);
 s = r.post(String.class, s);
 

Copyright © 2014. All Rights Reserved.