Class HttpClientAgent
- java.lang.Object
-
- io.vertx.reactivex.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
original
non 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 Future<Void>
close()
Close immediately (shutdown(0, TimeUnit.SECONDS
).Future<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.boolean
equals(Object o)
HttpClientAgent
getDelegate()
int
hashCode()
boolean
isMetricsEnabled()
Whether the metrics are enabled for this measured objectstatic HttpClientAgent
newInstance(HttpClientAgent arg)
Future<HttpClientRequest>
request()
Create an HTTP request to send to the server with the default host and port of the client.Future<HttpClientRequest>
request(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehost
andport
.Future<HttpClientRequest>
request(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port.Future<HttpClientRequest>
request(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehost
and default port.Future<HttpClientRequest>
request(RequestOptions options)
Create an HTTP request to send to the server.Completable
rxClose()
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 thehost
andport
.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 thehost
and default port.Single<HttpClientRequest>
rxRequest(RequestOptions options)
Create an HTTP request to send to the server.Completable
rxShutdown()
Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)
).Completable
rxShutdown(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.Future<Void>
shutdown()
Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)
).Future<Void>
shutdown(long timeout, TimeUnit unit)
Initiate the client shutdown sequence.String
toString()
Future<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.Future<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:
getDelegate
in interfaceHttpClient
- Specified by:
getDelegate
in interfaceMeasured
- Specified by:
getDelegate
in interfaceio.vertx.lang.rx.RxDelegate
-
isMetricsEnabled
public boolean isMetricsEnabled()
Whether the metrics are enabled for this measured object- Specified by:
isMetricsEnabled
in interfaceMeasured
- Returns:
true
if metrics are enabled
-
request
public Future<HttpClientRequest> request()
Create an HTTP request to send to the server with the default host and port of the client.- Specified by:
request
in 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:
rxRequest
in interfaceHttpClient
- Returns:
- a future notified when the request is ready to be sent
-
request
public Future<HttpClientRequest> request(RequestOptions options)
Create an HTTP request to send to the server.- Specified by:
request
in 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:
rxRequest
in interfaceHttpClient
- Parameters:
options
- the request options- Returns:
- a future notified when the request is ready to be sent
-
request
public Future<HttpClientRequest> request(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehost
andport
.- Specified by:
request
in 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 thehost
andport
.- Specified by:
rxRequest
in 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 Future<HttpClientRequest> request(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehost
and default port.- Specified by:
request
in 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 thehost
and default port.- Specified by:
rxRequest
in 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 Future<HttpClientRequest> request(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port.- Specified by:
request
in 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:
rxRequest
in interfaceHttpClient
- Parameters:
method
- the HTTP methodrequestURI
- the relative URI- Returns:
- a future notified when the request is ready to be sent
-
shutdown
public Future<Void> shutdown()
Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)
).- Specified by:
shutdown
in 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:
rxShutdown
in interfaceHttpClient
- Returns:
- a future completed when shutdown has completed
-
close
public Future<Void> close()
Close immediately (shutdown(0, TimeUnit.SECONDS
).- Specified by:
close
in interfaceHttpClient
- Returns:
- a future notified when the client is closed
-
rxClose
public Completable rxClose()
Close immediately (shutdown(0, TimeUnit.SECONDS
).- Specified by:
rxClose
in interfaceHttpClient
- Returns:
- a future notified when the client is closed
-
shutdown
public Future<Void> 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
timeout
expires, 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:
shutdown
in 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
timeout
expires, 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:
rxShutdown
in 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 Future<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 Future<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
options
object is compared using itsequals
method 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, settingforce
totrue
forces 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
options
object is compared using itsequals
method 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, settingforce
totrue
forces 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 Future<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)
-
-