Module methanol

Class Methanol

java.lang.Object
java.net.http.HttpClient
com.github.mizosoft.methanol.Methanol
All Implemented Interfaces:
AutoCloseable

public final class Methanol extends HttpClient
An HttpClient with interceptors, request decoration, HTTP caching and reactive extensions.

In addition to implementing the HttpClient interface, this class allows to:

  • Specify a base URI.
  • Specify a default request timeout.
  • Specify a read timeout.
  • Add a set of default HTTP headers for inclusion in requests if absent.
  • Add an HTTP caching layer.
  • Transparent response decompression.
  • Intercept requests and responses going through this client.
  • Specify an AdapterCodec to automatically convert to/from request/response bodies.
  • Get Publisher<HttpResponse<T>> for asynchronous requests.

A Methanol client relies on a standard HttpClient instance for sending requests, referred to as its backend. You can obtain builders for Methanol using either newBuilder() or newBuilder(HttpClient). The latter takes a prebuilt backend, while the former allows configuring a backend to be newly created each time Methanol.BaseBuilder.build() is invoked. Note that HttpCaches are not usable with a prebuilt backend.