Skip to content


Repository files navigation


Quickly get up and running with HTTP

A simple way to build and configure a HTTP client and work with the HTTP verbs;

HttpResponse response = anApacheClient().get(url,
        header("Accept", "application/json")

Will create a HTTP client, perform a GET with an Accept header and populate a simple HttpResponse object. Simple-HTTP currently wraps the Apache HTTP client but does so in a API agnostic way. Think of it as a smaller, simpler way to use Apache without all the boiler plate code.

See this blog post for an overview.


  1. No noise. Build and work with HTTP clients simply.
  2. Supports the basic HTTP verbs (GET, POST, PUT, DELETE).
  3. Easy to configure. Comes out of the box with sensible defaults but is easy to customise.
  4. Supplied with Hamcrest Matchers making testing your clients straight forward.
  5. Supports typical HTTP settings; SSL, follow redirects, timeouts, proxies etc.

Getting Started

Create a HTTP Client

HttpClient http = HttpClients.anApacheClient();

That's all there is to it. Now start making HTTP requests,

Making Requests

http.get(new URL(""));

and if you want to make the request with specific headers,

http.get(new URL(""),
        header("Accept", "application/json"),

Proxy support

You can set things up to go throw a proxy (e.g. localhost:8888) like this.

anApacheClient().with(proxy(new URL("http://username:password@localhost:8888"))).get(new URL(""));

Adding Basic Auth

You could add the Authorization header to your requests manually or just do the following,

AuthorisationCredentials credentials = basicAuth(username, password, new URL("")));
anApacheClient().with(credentials).get(new URL(""));

This will add basic auth headers, similar to below

Authorization: Basic aGVsbG86d29ybGQNCg==

to every request made to (but not to other URLs).

Adding OAuth Bearer Token

In a similar way to the basic auth headers above, you can add Bearer authorisation,

AuthorisationCredentials credentials = oAuth(accessToken("XystZ5ee"), new URL(""));
HttpResponse response = anApacheClient().with(credentials).get(new URL(""));

This will add the

Authorization: Bearer XystZ5ee

header to every request to http:\\

Adding Different Authorisation Headers

You can even mix the schemes

AuthorisationCredentials basicAuthCredentials = basicAuth(username("username"), password("secret"), new URL(""));
AuthorisationCredentials oAuthCredentials = oAuth(accessToken("XystZ5ee"), new URL(""));
HttpClient http = anApacheClient().with(basicAuthCredentials).with(oAuthCredentials);
http.get(new URL(""));
http.get(new URL(""));

which will use basic auth for requests to and bearer token auth for requests to


Available via the Maven repository.

Continuous Integration

Travis CI
Code Coverage
Static Code Analysis (SonarQube)