Module io.inverno.mod.http.client
module io.inverno.mod.http.client
The Inverno framework HTTP client module provides a HTTP1.x and HTTP/2 client.
It defines the following sockets:
- httpClientConfiguration
- the HTTP client module configuration
- netService (required)
- the Net service used to create the HTTP client
- resourceService (required)
- the resource service used to load resources required by the HTTP client (eg. key store...)
- reactor (required)
- the reactor used in the connection pool
- headerCodecs
- custom header codecs
- parameterConverter
- override the default parameter converter used in
Parameter
instances to convert their values
It exposes the following beans:
- configuration
- the HTTP client module configuration
- httpClient
- the HTTP client
A simple HTTP client using the default configuration and sending a GET request can be created as follows:
NetService netService = null;
Reactor reactor = null;
ResourceService resourceService = null;
Client client = Application.with(new Client.Builder(netService, reactor, resourceService)
.configuration(HttpClientConfigurationLoader.load(conf -> conf.http_protocol_versions(Set.of(HttpVersion.HTTP_2_0))))
).run();
Endpoint<ExchangeContext> endpoint = client.httpClient().endpoint("example.org", 80).build();
String responseBody = endpoint
.exchange(Method.GET, "/")
.flatMap(Exchange::response)
.flatMapMany(response -> response.body().string().stream())
.reduceWith(() -> new StringBuilder(), (acc, chunk) -> acc.append(chunk))
.map(StringBuilder::toString).block();
- Since:
- 1.6
- Author:
- Jeremy Kuhn
-
Packages
PackageDescriptionInverno HTTP client API and module configuration.Inverno HTTP client WebSocket API. -
Modules
ModifierModuleDescriptiontransitiveDefines the foundational APIs of the Inverno framework modules.transitiveThe Inverno framework HTTP base module defines the base APIs and services for HTTP client and server implementations.