Class HttpClientAgent
- All Implemented Interfaces:
io.vertx.lang.rx.RxDelegate, 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.
NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclose()Close immediately (shutdown(0, TimeUnit.SECONDS).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.booleaninthashCode()booleanWhether the metrics are enabled for this measured objectstatic HttpClientAgentrequest()Create an HTTP request to send to the server with the default host and port of the client.request(HttpMethod method, int port, String host, String requestURI) Create an HTTP request to send to the server at thehostandport.request(HttpMethod method, String requestURI) Create an HTTP request to send to the server at the default host and port.request(HttpMethod method, String host, String requestURI) Create an HTTP request to send to the server at thehostand default port.request(RequestOptions options) Create an HTTP request to send to the server.rxClose()Close immediately (shutdown(0, TimeUnit.SECONDS).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.Create an HTTP request to send to the server with the default host and port of the client.rxRequest(HttpMethod method, int port, String host, String requestURI) Create an HTTP request to send to the server at thehostandport.rxRequest(HttpMethod method, String requestURI) Create an HTTP request to send to the server at the default host and port.rxRequest(HttpMethod method, String host, String requestURI) Create an HTTP request to send to the server at thehostand default port.rxRequest(RequestOptions options) Create an HTTP request to send to the server.Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).rxShutdown(long timeout, TimeUnit unit) CallsHttpClient.shutdown().rxShutdown(Duration timeout) Initiate the client shutdown sequence.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.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.shutdown()Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).CallsHttpClient.shutdown().Initiate the client shutdown sequence.toString()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.
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
HttpClientAgent
-
HttpClientAgent
-
-
Method Details
-
toString
-
equals
-
hashCode
-
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
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
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
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
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 Future<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
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
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
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
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
Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).- Specified by:
shutdownin interfaceHttpClient- Returns:
- a future completed when shutdown has completed
-
rxShutdown
Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)).- Specified by:
rxShutdownin interfaceHttpClient- Returns:
- a future completed when shutdown has completed
-
close
Close immediately (shutdown(0, TimeUnit.SECONDS).- Specified by:
closein interfaceHttpClient- Returns:
- a future notified when the client is closed
-
rxClose
Close immediately (shutdown(0, TimeUnit.SECONDS).- Specified by:
rxClosein interfaceHttpClient- Returns:
- a future notified when the client is closed
-
shutdown
CallsHttpClient.shutdown().- Specified by:
shutdownin interfaceHttpClient- Parameters:
timeout-unit-- Returns:
-
rxShutdown
CallsHttpClient.shutdown().- Specified by:
rxShutdownin interfaceHttpClient- Parameters:
timeout-unit-- Returns:
-
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
-
rxUpdateSSLOptions
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
-
rxUpdateSSLOptions
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
-
rxConnect
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
-
shutdown
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
- Parameters:
timeout- the amount of time after which all resources are forcibly closed- Returns:
- a future notified when the client is closed
-
rxShutdown
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
- Parameters:
timeout- the amount of time after which all resources are forcibly closed- Returns:
- a future notified when the client is closed
-
newInstance
-