Class HttpClientAgent
- java.lang.Object
-
- io.vertx.rxjava3.core.http.HttpClientAgent
-
- All Implemented Interfaces:
io.vertx.lang.rx.RxDelegate,HttpClient,Measured
public class HttpClientAgent extends Object implements io.vertx.lang.rx.RxDelegate, HttpClient, Measured
An asynchronous HTTP client.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.
NOTE: This class has been automatically generated from the
originalnon RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static io.vertx.lang.rx.TypeArg<HttpClientAgent>__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description HttpClientAgent(HttpClientAgent delegate)HttpClientAgent(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Completableclose()Close immediately (shutdown(0, TimeUnit.SECONDS).Single<HttpClientConnection>connect(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.booleanequals(Object o)HttpClientAgentgetDelegate()inthashCode()booleanisMetricsEnabled()Whether the metrics are enabled for this measured objectstatic HttpClientAgentnewInstance(HttpClientAgent arg)Single<HttpClientRequest>request()Create an HTTP request to send to the server with the default host and port of the client.Single<HttpClientRequest>request(HttpMethod method, int port, String host, String requestURI)Create an HTTP request to send to the server at thehostandport.Single<HttpClientRequest>request(HttpMethod method, String requestURI)Create an HTTP request to send to the server at the default host and port.Single<HttpClientRequest>request(HttpMethod method, String host, String requestURI)Create an HTTP request to send to the server at thehostand default port.Single<HttpClientRequest>request(RequestOptions options)Create an HTTP request to send to the server.CompletablerxClose()Close immediately (shutdown(0, TimeUnit.SECONDS).Single<HttpClientConnection>rxConnect(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.Single<HttpClientRequest>rxRequest()Create an HTTP request to send to the server with the default host and port of the client.Single<HttpClientRequest>rxRequest(HttpMethod method, int port, String host, String requestURI)Create an HTTP request to send to the server at thehostandport.Single<HttpClientRequest>rxRequest(HttpMethod method, String requestURI)Create an HTTP request to send to the server at the default host and port.Single<HttpClientRequest>rxRequest(HttpMethod method, String host, String requestURI)Create an HTTP request to send to the server at thehostand default port.Single<HttpClientRequest>rxRequest(RequestOptions options)Create an HTTP request to send to the server.CompletablerxShutdown()Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).CompletablerxShutdown(long timeout, TimeUnit unit)Initiate the client shutdown sequence.Single<Boolean>rxUpdateSSLOptions(ClientSSLOptions options)Update the client with new SSLoptions, the update happens if the options object is valid and different from the existing options object.Single<Boolean>rxUpdateSSLOptions(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.Completableshutdown()Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).Completableshutdown(long timeout, TimeUnit unit)Initiate the client shutdown sequence.StringtoString()Single<Boolean>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.Single<Boolean>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.
-
-
-
Field Detail
-
__TYPE_ARG
public static final io.vertx.lang.rx.TypeArg<HttpClientAgent> __TYPE_ARG
-
-
Constructor Detail
-
HttpClientAgent
public HttpClientAgent(HttpClientAgent delegate)
-
HttpClientAgent
public HttpClientAgent(Object delegate)
-
-
Method Detail
-
getDelegate
public HttpClientAgent getDelegate()
- Specified by:
getDelegatein interfaceHttpClient- Specified by:
getDelegatein interfaceMeasured- Specified by:
getDelegatein interfaceio.vertx.lang.rx.RxDelegate
-
isMetricsEnabled
public boolean isMetricsEnabled()
Whether the metrics are enabled for this measured object- Specified by:
isMetricsEnabledin interfaceMeasured- Returns:
trueif metrics are enabled
-
request
public Single<HttpClientRequest> request()
Create an HTTP request to send to the server with the default host and port of the client.- Specified by:
requestin interfaceHttpClient- Returns:
- a future notified when the request is ready to be sent
-
rxRequest
public Single<HttpClientRequest> rxRequest()
Create an HTTP request to send to the server with the default host and port of the client.- Specified by:
rxRequestin interfaceHttpClient- Returns:
- a future notified when the request is ready to be sent
-
request
public Single<HttpClientRequest> request(RequestOptions options)
Create an HTTP request to send to the server.- Specified by:
requestin interfaceHttpClient- Parameters:
options- the request options- Returns:
- a future notified when the request is ready to be sent
-
rxRequest
public Single<HttpClientRequest> rxRequest(RequestOptions options)
Create an HTTP request to send to the server.- Specified by:
rxRequestin interfaceHttpClient- Parameters:
options- the request options- Returns:
- a future notified when the request is ready to be sent
-
request
public Single<HttpClientRequest> request(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehostandport.- Specified by:
requestin interfaceHttpClient- Parameters:
method- the HTTP methodport- the porthost- the hostrequestURI- the relative URI- Returns:
- a future notified when the request is ready to be sent
-
rxRequest
public Single<HttpClientRequest> rxRequest(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehostandport.- Specified by:
rxRequestin interfaceHttpClient- Parameters:
method- the HTTP methodport- the porthost- the hostrequestURI- the relative URI- Returns:
- a future notified when the request is ready to be sent
-
request
public Single<HttpClientRequest> request(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehostand default port.- Specified by:
requestin interfaceHttpClient- Parameters:
method- the HTTP methodhost- the hostrequestURI- the relative URI- Returns:
- a future notified when the request is ready to be sent
-
rxRequest
public Single<HttpClientRequest> rxRequest(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehostand default port.- Specified by:
rxRequestin interfaceHttpClient- Parameters:
method- the HTTP methodhost- the hostrequestURI- the relative URI- Returns:
- a future notified when the request is ready to be sent
-
request
public Single<HttpClientRequest> request(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port.- Specified by:
requestin interfaceHttpClient- Parameters:
method- the HTTP methodrequestURI- the relative URI- Returns:
- a future notified when the request is ready to be sent
-
rxRequest
public Single<HttpClientRequest> rxRequest(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port.- Specified by:
rxRequestin interfaceHttpClient- Parameters:
method- the HTTP methodrequestURI- the relative URI- Returns:
- a future notified when the request is ready to be sent
-
shutdown
public Completable shutdown()
Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).- Specified by:
shutdownin interfaceHttpClient- Returns:
- a future completed when shutdown has completed
-
rxShutdown
public Completable rxShutdown()
Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).- Specified by:
rxShutdownin interfaceHttpClient- Returns:
- a future completed when shutdown has completed
-
close
public Completable close()
Close immediately (shutdown(0, TimeUnit.SECONDS).- Specified by:
closein interfaceHttpClient- Returns:
- a future notified when the client is closed
-
rxClose
public Completable rxClose()
Close immediately (shutdown(0, TimeUnit.SECONDS).- Specified by:
rxClosein interfaceHttpClient- Returns:
- a future notified when the client is closed
-
shutdown
public Completable shutdown(long timeout, TimeUnit unit)
Initiate the client shutdown sequence.Connections are taken out of service and closed when all inflight requests are processed, client connection are immediately removed from the pool. When all connections are closed the client is closed. When the
timeoutexpires, all unclosed connections are immediately closed.- HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close
- HTTP/1.x client connection will be closed after the current response is received
- Specified by:
shutdownin interfaceHttpClient- Parameters:
timeout- the amount of time after which all resources are forcibly closedunit- the of the timeout- Returns:
- a future notified when the client is closed
-
rxShutdown
public Completable rxShutdown(long timeout, TimeUnit unit)
Initiate the client shutdown sequence.Connections are taken out of service and closed when all inflight requests are processed, client connection are immediately removed from the pool. When all connections are closed the client is closed. When the
timeoutexpires, all unclosed connections are immediately closed.- HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close
- HTTP/1.x client connection will be closed after the current response is received
- Specified by:
rxShutdownin interfaceHttpClient- Parameters:
timeout- the amount of time after which all resources are forcibly closedunit- the of the timeout- Returns:
- a future notified when the client is closed
-
updateSSLOptions
public Single<Boolean> updateSSLOptions(ClientSSLOptions options)
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
-
rxUpdateSSLOptions
public Single<Boolean> rxUpdateSSLOptions(ClientSSLOptions options)
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
public Single<Boolean> updateSSLOptions(ClientSSLOptions options, boolean force)
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
-
rxUpdateSSLOptions
public Single<Boolean> rxUpdateSSLOptions(ClientSSLOptions options, boolean force)
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
public Single<HttpClientConnection> connect(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.- Parameters:
options- the server connect options- Returns:
- a future notified when the connection is available
-
rxConnect
public Single<HttpClientConnection> rxConnect(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.- Parameters:
options- the server connect options- Returns:
- a future notified when the connection is available
-
newInstance
public static HttpClientAgent newInstance(HttpClientAgent arg)
-
-