synchronous & asynchronous (non-blocking) requests using UniRest

Sometimes, well most of the time, you want your application to be asynchronous and not block, Unirest supports this in Java using anonymous callbacks, or direct method placement:

Future<HttpResponse<JsonNode>> future = Unirest.post("http://httpbin.org/post")  .header("accept", "application/json")  .field("param1", "value1")  .field("param2", "value2")  .asJsonAsync(new Callback<JsonNode>() {	public void failed(UnirestException e) {		System.out.println("The request has failed");	}	public void completed(HttpResponse<JsonNode> response) {		 int code = response.getStatus();	     Map<String, String> headers = response.getHeaders();	     JsonNode body = response.getBody();	     InputStream rawBody = response.getRawBody();	}	public void cancelled() {		System.out.println("The request has been cancelled");	}});