Skip to content

Instantly share code, notes, and snippets.

@jfarcand
Created January 7, 2011 21:57
Show Gist options
  • Save jfarcand/770187 to your computer and use it in GitHub Desktop.
Save jfarcand/770187 to your computer and use it in GitHub Desktop.
AsyncHttpClient Simplified API
// SimpleAsyncHttpClient class API:
public Future<Response> post(BodyGenerator bodyGenerator) throws IOException ;
public Future<Response> post(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer) throws IOException ;
public Future<Response> put(BodyGenerator bodyGenerator, BodyConsumer bodyConsumer) throws IOException ;
public Future<Response> put(BodyGenerator bodyGenerator) throws IOException ;
public Future<Response> get(BodyConsumer bodyConsumer) throws IOException ;
public Future<Response> delete() throws IOException ;
public Future<Response> delete(BodyConsumer bodyConsumer) throws IOException;
public Future<Response> head() throws IOException
public Future<Response> options() throws IOException ;
public Future<Response> options(BodyConsumer bodyConsumer) throws IOException ;
public Future<Response> trace() throws IOException ;
public Future<Response> trace(BodyConsumer bodyConsumer) throws IOException ;
// Can be used like this. BodyConsumer and BobyGenerator will be added to the lib like InputStreamBodyGenerator,
// FileBodyConsumer, etc.
SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder()
.setUrl("http://..")
.setProxyHost("http://...")
.addHeader("foo","bar")
.setRealmPrincipal("me")
.setRealmPassword("pwd")
.build();
OutputStream stream = ....;
client.get(new OutputStreamBodyConsumer(stream));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment