Interface WebClient
- All Superinterfaces:
HttpClient<HttpClientRequest>, ReleasableResource, RuntimeType.Api<WebClientConfig>
- All Known Implementing Classes:
DirectWebClient
HTTP client.
-
Method Summary
Modifier and TypeMethodDescriptionstatic WebClientConfig.Builderbuilder()Create a new builder of the HTTP protocol, that can be used with any supported version.<T, C extends ProtocolConfig>
TTo switch to a non-HTTP protocol client (or a client of a specific HTTP version) using its config configured when creating the client, or default config if none configured.<T, C extends ProtocolConfig>
TTo switch to a non-HTTP protocol client (or a client of a specific HTTP version).Cookie manager to use by this client.static WebClientcreate()Create a new web client with default configuration.static WebClientcreate(WebClientConfig config) Create a new webclient with customized configuration.static WebClientcreate(Consumer<WebClientConfig.Builder> consumer) Create a new webclient, customizing its configuration.executor()Executor services, uses virtual threads.default voidresponseReceived(WebClientProtocolResponse response) Notify active HTTP protocol implementations about a transport response received by this client.Active TCP protocol IDs in preference order.Methods inherited from interface HttpClient
closeResource, delete, delete, get, get, head, head, method, options, options, patch, patch, post, post, put, put, trace, traceModifier and TypeMethodDescriptiondefault voidGracefully close all opened client specific connections.default HttpClientRequestdelete()Shortcut for delete method with default path.default HttpClientRequestShortcut for delete method with a path.default HttpClientRequestget()Shortcut for get method with default path.default HttpClientRequestShortcut for get method with a path.default HttpClientRequesthead()Shortcut for head method with default path.default HttpClientRequestShortcut for head method with a path.Create a request for a method.default HttpClientRequestoptions()Shortcut for options method with default path.default HttpClientRequestShortcut for options method with a path.default HttpClientRequestpatch()Shortcut for patch method with default path.default HttpClientRequestShortcut for patch method with a path.default HttpClientRequestpost()Shortcut for post method with default path.default HttpClientRequestShortcut for post method with a path.default HttpClientRequestput()Shortcut for put method with default path.default HttpClientRequestShortcut for put method with a path.default HttpClientRequesttrace()Shortcut for trace method with default path.default HttpClientRequestShortcut for trace method with a path.Methods inherited from interface ReleasableResource
releaseResourceModifier and TypeMethodDescriptiondefault voidReleases the resource, and if this resource is re-usable, enabled reuse.Methods inherited from interface RuntimeType.Api
prototypeModifier and TypeMethodDescriptionThe prototype as it was received when creating this runtime object instance.
-
Method Details
-
builder
Create a new builder of the HTTP protocol, that can be used with any supported version. Which versions are supported is determined by the classpath, HTTP/1.1 is always supported. To support a specific HTTP version only, you can useWebClientConfig.BuilderBase.addProtocolPreference(java.util.List).- Returns:
- new HTTP client builder
-
create
Create a new web client with default configuration.- Returns:
- a new web client
-
create
Create a new webclient with customized configuration.- Parameters:
config- configuration to use- Returns:
- a new web client
-
create
Create a new webclient, customizing its configuration.- Parameters:
consumer- configuration consumer- Returns:
- a new web client
-
client
To switch to a non-HTTP protocol client (or a client of a specific HTTP version). The resulting protocol will use this client as a base, so it will share all configuration that is relevant for the protocol.- Type Parameters:
T- type of the protocol clientC- type of the protocol config- Parameters:
protocol- protocol instance, usually defined as a constant on the protocol interfaceprotocolConfig- configuration of the protocol to be used (if customization is required)- Returns:
- a new protocol client instance
-
client
To switch to a non-HTTP protocol client (or a client of a specific HTTP version) using its config configured when creating the client, or default config if none configured. The resulting protocol will use this client as a base, so it will share all configuration that is relevant for the protocol.- Type Parameters:
T- type of the protocol clientC- type of the protocol config- Parameters:
protocol- protocol instance, usually defined as a constant on the protocol interface- Returns:
- a new protocol client instance
-
tcpProtocolIds
Active TCP protocol IDs in preference order. Implementations that do not expose their active protocols return an empty list. The returned list is an immutable snapshot.This method must not be called from
ClientProtocolProvider.protocol(WebClient, Object)while this client is being constructed. Protocol clients should retain theWebClientinstance and obtain the protocol IDs after construction completes.- Returns:
- unmodifiable list of active TCP protocol IDs
- Throws:
IllegalStateException- if the protocol inventory is not yet available
-
responseReceived
Notify active HTTP protocol implementations about a transport response received by this client.This notification lets one protocol observe response metadata produced by another protocol without creating dependencies between protocol modules. For example, a protocol may use an
Alt-Svcresponse header to discover an alternative service.- Parameters:
response- received protocol response
-
executor
-
cookieManager
WebClientCookieManager cookieManager()Cookie manager to use by this client.- Returns:
- cookie manager
-