Skip to content

Jetty Client based implementation of the Everit Async HTTPClient API

License

Notifications You must be signed in to change notification settings

everit-org/everit-httpclient-jettyclient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

everit-async-httpclient-jettyclient

Jetty Client based implementation of the asynchronous Everit HTTP Client API.

Usage

// Instantiate and configure a jetty http client
org.eclipse.jetty.client.HttpClient jettyClient = ...

// Pass the jetty http client to the connector class
HttpClient httpClient = new JettyClientHttpClient(jettyClient);

// Use the Everit HTTP Client API to send HTTP requests. E.g.:

// Craete the request with a builder
HttpRequest request = HttpRequest.builder().url("https://mypage.com");

// Send the request asynchronously
Single<HttpResponse> responseSingle = httpClient.send(request);

responseSingle.subscribe(httpResponse -> {
  System.out.println("Status: " + httpResponse.getStatus());
  
  // Get the body. It is low level to read the body with the
  // AsyncContentProvider interface, so it is better to use the Util
  // class to read the content as a Single.
  Single<String> bodySingle = AsyncContentUtil.readString(
      httpResponse.getBody(), StandardCharsets.UTF8);
  
  bodySingle.subscribe(content -> {
    httpResponse.close();
    System.out.println(content);
  }, error -> httpResponse.close());
});

For more information, see the documentation of Everit HTTP Client

About

Jetty Client based implementation of the Everit Async HTTPClient API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages