Interface HttpClientAgent
- All Superinterfaces:
HttpClient, Measured
It allows you to make requests to HTTP servers, and a single client can make requests to any server.
The client can also pool HTTP connections.
For pooling to occur, keep-alive must be true on the HttpClientOptions (default is true).
In this case connections will be pooled and re-used if there are pending HTTP requests waiting to get a connection,
otherwise they will be closed.
This gives the benefits of keep alive when the client is loaded but means we don't keep connections hanging around unnecessarily when there would be no benefits anyway.
The client also supports pipe-lining of requests. Pipe-lining means another request is sent on the same connection before the response from the preceding one has returned. Pipe-lining is not appropriate for all requests.
To enable pipe-lining, it must be enabled on the HttpClientOptions (default is false).
When pipe-lining is enabled the connection will be automatically closed when all in-flight responses have returned and there are no outstanding pending requests to write.
The client is designed to be reused between requests.
- Author:
- Julien Viet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Function<HttpClientResponse, Future<RequestOptions>> Constant containing the default redirect handler of used by the client. -
Method Summary
Modifier and TypeMethodDescriptionconnect(HttpConnectOptions options) Connect to a remote HTTP server with the specificoptions, the connection is un-pooled and the management of the connection is left to the user.updateSSLOptions(ClientSSLOptions options) Update the client with new SSLoptions, the update happens if the options object is valid and different from the existing options object.updateSSLOptions(ClientSSLOptions options, boolean force) Update the client with new SSLoptions, the update happens if the options object is valid and different from the existing options object.Methods inherited from interface HttpClient
close, request, request, request, request, request, shutdown, shutdown, shutdownMethods inherited from interface Measured
isMetricsEnabled
-
Field Details
-
DEFAULT_REDIRECT_HANDLER
Constant containing the default redirect handler of used by the client. This is useful for building redirect handlers that need to delegate to the default behavior.
-
-
Method Details
-
updateSSLOptions
Update the client with new SSL
options, the update happens if the options object is valid and different from the existing options object.The boolean succeeded future result indicates whether the update occurred.
- Parameters:
options- the new SSL options- Returns:
- a future signaling the update success
-
updateSSLOptions
Update the client with new SSL
options, the update happens if the options object is valid and different from the existing options object.The
optionsobject is compared using itsequalsmethod against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, settingforcetotrueforces the update.The boolean succeeded future result indicates whether the update occurred.
- Parameters:
options- the new SSL optionsforce- force the update when options are equals- Returns:
- a future signaling the update success
-
connect
Connect to a remote HTTP server with the specificoptions, the connection is un-pooled and the management of the connection is left to the user.- Parameters:
options- the server connect options- Returns:
- a future notified when the connection is available
-