Class HttpClient
- java.lang.Object
 - 
- io.vertx.rxjava3.core.http.HttpClient
 
 
- 
- All Implemented Interfaces:
 Measured
public class HttpClient extends Object implements Measured
An asynchronous HTTP client.It allows you to make requests to HTTP servers, and a single client can make requests to any server.
It also allows you to open WebSockets to servers.
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 theoriginalnon RX-ified interface using Vert.x codegen. 
- 
- 
Field Summary
Fields Modifier and Type Field Description static TypeArg<HttpClient>__TYPE_ARG 
- 
Constructor Summary
Constructors Constructor Description HttpClient(HttpClient delegate)HttpClient(Object delegate) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.reactivex.rxjava3.core.Completableclose()Close the client.HttpClientconnectionHandler(Handler<HttpConnection> handler)Set a connection handler for the client.booleanequals(Object o)HttpClientgetDelegate()inthashCode()booleanisMetricsEnabled()Whether the metrics are enabled for this measured objectstatic HttpClientnewInstance(HttpClient arg)HttpClientredirectHandler(Function<HttpClientResponse,io.reactivex.rxjava3.core.Single<RequestOptions>> handler)Set a redirect handler for the http client.io.reactivex.rxjava3.core.Single<HttpClientRequest>request(HttpMethod method, int port, String host, String requestURI)Create an HTTP request to send to the server at thehostandport.io.reactivex.rxjava3.core.Single<HttpClientRequest>request(HttpMethod method, String requestURI)Create an HTTP request to send to the server at the default host and port.io.reactivex.rxjava3.core.Single<HttpClientRequest>request(HttpMethod method, String host, String requestURI)Create an HTTP request to send to the server at thehostand default port.io.reactivex.rxjava3.core.Single<HttpClientRequest>request(RequestOptions options)Create an HTTP request to send to the server.io.reactivex.rxjava3.core.CompletablerxClose()Close the client.io.reactivex.rxjava3.core.Single<HttpClientRequest>rxRequest(HttpMethod method, int port, String host, String requestURI)Create an HTTP request to send to the server at thehostandport.io.reactivex.rxjava3.core.Single<HttpClientRequest>rxRequest(HttpMethod method, String requestURI)Create an HTTP request to send to the server at the default host and port.io.reactivex.rxjava3.core.Single<HttpClientRequest>rxRequest(HttpMethod method, String host, String requestURI)Create an HTTP request to send to the server at thehostand default port.io.reactivex.rxjava3.core.Single<HttpClientRequest>rxRequest(RequestOptions options)Create an HTTP request to send to the server.io.reactivex.rxjava3.core.CompletablerxUpdateSSLOptions(SSLOptions options)LikeupdateSSLOptions(io.vertx.core.net.SSLOptions)but supplying a handler that will be called when the update happened (or has failed).io.reactivex.rxjava3.core.Single<WebSocket>rxWebSocket(int port, String host, String requestURI)Connect a WebSocket to the specified port, host and relative request URIio.reactivex.rxjava3.core.Single<WebSocket>rxWebSocket(WebSocketConnectOptions options)Connect a WebSocket with the specified options.io.reactivex.rxjava3.core.Single<WebSocket>rxWebSocket(String requestURI)Connect a WebSocket at the relative request URI using the default host and portio.reactivex.rxjava3.core.Single<WebSocket>rxWebSocket(String host, String requestURI)Connect a WebSocket to the host and relative request URI and default portio.reactivex.rxjava3.core.Single<WebSocket>rxWebSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)Connect a WebSocket with the specified absolute url, with the specified headers, using the specified version of WebSockets, and the specified WebSocket sub protocols.StringtoString()io.reactivex.rxjava3.core.CompletableupdateSSLOptions(SSLOptions options)LikeupdateSSLOptions(io.vertx.core.net.SSLOptions)but supplying a handler that will be called when the update happened (or has failed).io.reactivex.rxjava3.core.Single<WebSocket>webSocket(int port, String host, String requestURI)Connect a WebSocket to the specified port, host and relative request URIio.reactivex.rxjava3.core.Single<WebSocket>webSocket(WebSocketConnectOptions options)Connect a WebSocket with the specified options.io.reactivex.rxjava3.core.Single<WebSocket>webSocket(String requestURI)Connect a WebSocket at the relative request URI using the default host and portio.reactivex.rxjava3.core.Single<WebSocket>webSocket(String host, String requestURI)Connect a WebSocket to the host and relative request URI and default portio.reactivex.rxjava3.core.Single<WebSocket>webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)Connect a WebSocket with the specified absolute url, with the specified headers, using the specified version of WebSockets, and the specified WebSocket sub protocols. 
 - 
 
- 
- 
Field Detail
- 
__TYPE_ARG
public static final TypeArg<HttpClient> __TYPE_ARG
 
 - 
 
- 
Constructor Detail
- 
HttpClient
public HttpClient(HttpClient delegate)
 
- 
HttpClient
public HttpClient(Object delegate)
 
 - 
 
- 
Method Detail
- 
getDelegate
public HttpClient getDelegate()
- Specified by:
 getDelegatein interfaceMeasured
 
- 
isMetricsEnabled
public boolean isMetricsEnabled()
Whether the metrics are enabled for this measured object- Specified by:
 isMetricsEnabledin interfaceMeasured- Returns:
 trueif metrics are enabled
 
- 
request
public io.reactivex.rxjava3.core.Single<HttpClientRequest> request(RequestOptions options)
Create an HTTP request to send to the server. Thehandleris called when the request is ready to be sent.- Parameters:
 options- the request options- Returns:
 
 
- 
rxRequest
public io.reactivex.rxjava3.core.Single<HttpClientRequest> rxRequest(RequestOptions options)
Create an HTTP request to send to the server. Thehandleris called when the request is ready to be sent.- Parameters:
 options- the request options- Returns:
 
 
- 
request
public io.reactivex.rxjava3.core.Single<HttpClientRequest> request(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehostandport. Thehandleris called when the request is ready to be sent.- Parameters:
 method- the HTTP methodport- the porthost- the hostrequestURI- the relative URI- Returns:
 
 
- 
rxRequest
public io.reactivex.rxjava3.core.Single<HttpClientRequest> rxRequest(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehostandport. Thehandleris called when the request is ready to be sent.- Parameters:
 method- the HTTP methodport- the porthost- the hostrequestURI- the relative URI- Returns:
 
 
- 
request
public io.reactivex.rxjava3.core.Single<HttpClientRequest> request(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehostand default port. Thehandleris called when the request is ready to be sent.- Parameters:
 method- the HTTP methodhost- the hostrequestURI- the relative URI- Returns:
 
 
- 
rxRequest
public io.reactivex.rxjava3.core.Single<HttpClientRequest> rxRequest(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehostand default port. Thehandleris called when the request is ready to be sent.- Parameters:
 method- the HTTP methodhost- the hostrequestURI- the relative URI- Returns:
 
 
- 
request
public io.reactivex.rxjava3.core.Single<HttpClientRequest> request(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port. Thehandleris called when the request is ready to be sent.- Parameters:
 method- the HTTP methodrequestURI- the relative URI- Returns:
 
 
- 
rxRequest
public io.reactivex.rxjava3.core.Single<HttpClientRequest> rxRequest(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port. Thehandleris called when the request is ready to be sent.- Parameters:
 method- the HTTP methodrequestURI- the relative URI- Returns:
 
 
- 
webSocket
public io.reactivex.rxjava3.core.Single<WebSocket> webSocket(int port, String host, String requestURI)
Connect a WebSocket to the specified port, host and relative request URI- Parameters:
 port- the porthost- the hostrequestURI- the relative URI- Returns:
 
 
- 
rxWebSocket
public io.reactivex.rxjava3.core.Single<WebSocket> rxWebSocket(int port, String host, String requestURI)
Connect a WebSocket to the specified port, host and relative request URI- Parameters:
 port- the porthost- the hostrequestURI- the relative URI- Returns:
 
 
- 
webSocket
public io.reactivex.rxjava3.core.Single<WebSocket> webSocket(String host, String requestURI)
Connect a WebSocket to the host and relative request URI and default port- Parameters:
 host- the hostrequestURI- the relative URI- Returns:
 
 
- 
rxWebSocket
public io.reactivex.rxjava3.core.Single<WebSocket> rxWebSocket(String host, String requestURI)
Connect a WebSocket to the host and relative request URI and default port- Parameters:
 host- the hostrequestURI- the relative URI- Returns:
 
 
- 
webSocket
public io.reactivex.rxjava3.core.Single<WebSocket> webSocket(String requestURI)
Connect a WebSocket at the relative request URI using the default host and port- Parameters:
 requestURI- the relative URI- Returns:
 
 
- 
rxWebSocket
public io.reactivex.rxjava3.core.Single<WebSocket> rxWebSocket(String requestURI)
Connect a WebSocket at the relative request URI using the default host and port- Parameters:
 requestURI- the relative URI- Returns:
 
 
- 
webSocket
public io.reactivex.rxjava3.core.Single<WebSocket> webSocket(WebSocketConnectOptions options)
Connect a WebSocket with the specified options.- Parameters:
 options- the request options- Returns:
 
 
- 
rxWebSocket
public io.reactivex.rxjava3.core.Single<WebSocket> rxWebSocket(WebSocketConnectOptions options)
Connect a WebSocket with the specified options.- Parameters:
 options- the request options- Returns:
 
 
- 
webSocketAbs
public io.reactivex.rxjava3.core.Single<WebSocket> webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)
Connect a WebSocket with the specified absolute url, with the specified headers, using the specified version of WebSockets, and the specified WebSocket sub protocols.- Parameters:
 url- the absolute urlheaders- the headersversion- the WebSocket versionsubProtocols- the subprotocols to use- Returns:
 
 
- 
rxWebSocketAbs
public io.reactivex.rxjava3.core.Single<WebSocket> rxWebSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)
Connect a WebSocket with the specified absolute url, with the specified headers, using the specified version of WebSockets, and the specified WebSocket sub protocols.- Parameters:
 url- the absolute urlheaders- the headersversion- the WebSocket versionsubProtocols- the subprotocols to use- Returns:
 
 
- 
updateSSLOptions
public io.reactivex.rxjava3.core.Completable updateSSLOptions(SSLOptions options)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions)but supplying a handler that will be called when the update happened (or has failed).- Parameters:
 options- the new SSL options- Returns:
 
 
- 
rxUpdateSSLOptions
public io.reactivex.rxjava3.core.Completable rxUpdateSSLOptions(SSLOptions options)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions)but supplying a handler that will be called when the update happened (or has failed).- Parameters:
 options- the new SSL options- Returns:
 
 
- 
connectionHandler
public HttpClient connectionHandler(Handler<HttpConnection> handler)
Set a connection handler for the client. This handler is called when a new connection is established.- Parameters:
 handler-- Returns:
 - a reference to this, so the API can be used fluently
 
 
- 
redirectHandler
public HttpClient redirectHandler(Function<HttpClientResponse,io.reactivex.rxjava3.core.Single<RequestOptions>> handler)
Set a redirect handler for the http client.The redirect handler is called when a
3xxresponse is received and the request is configured to follow redirects withHttpClientRequest.setFollowRedirects(boolean).The redirect handler is passed the
HttpClientResponse, it can return anHttpClientRequestornull.- when null is returned, the original response is processed by the original request response handler
 - when a new 
Futureis returned, the client will send this new request 
The handler must return a
Futureunsent so the client can further configure it and send it.- Parameters:
 handler- the new redirect handler- Returns:
 - a reference to this, so the API can be used fluently
 
 
- 
close
public io.reactivex.rxjava3.core.Completable close()
Close the client. Closing will close down any pooled connections. Clients should always be closed after use.- Returns:
 
 
- 
rxClose
public io.reactivex.rxjava3.core.Completable rxClose()
Close the client. Closing will close down any pooled connections. Clients should always be closed after use.- Returns:
 
 
- 
newInstance
public static HttpClient newInstance(HttpClient arg)
 
 - 
 
 -