Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Include JDK 8 syntax example and remove toString on default client
Browse files Browse the repository at this point in the history
  • Loading branch information
biasedbit committed Apr 17, 2013
1 parent 034b78d commit de6023c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 10 additions & 3 deletions README.md
Expand Up @@ -47,10 +47,17 @@ client.terminate();

In asynchronous mode, an event listener is attached to the object returned by the http client when a request execution is submitted. Attaching this listener allows the programmer to define some computation to occur when the request finishes.

Only the relevant parts are shown here.

```java
// Execute the request
// Execute an asynchronous request, JDK 8 syntax
RequestFuture<String> future = client.execute("biasedbit.com", 80, request, new BodyAsStringProcessor());
future.addListener((future) -> {
System.out.println(future);
if (future.isSuccessfulResponse()) System.out.println(future.getProcessedResult());
client.terminate();
}
});

// Execute an asynchronous request
RequestFuture<String> future = client.execute("biasedbit.com", 80, request, new BodyAsStringProcessor());
future.addListener(new RequestFutureListener<String>() {
@Override public void operationComplete(RequestFuture<String> future)
Expand Down
Expand Up @@ -743,8 +743,4 @@ public void setSslContextFactory(SslContextFactory sslContextFactory) {

this.sslContextFactory = sslContextFactory;
}

// object overrides -----------------------------------------------------------------------------------------------

@Override public String toString() { return getClass().getSimpleName() + '@' + Integer.toHexString(hashCode()); }
}

0 comments on commit de6023c

Please sign in to comment.