Class HttpClient
- java.lang.Object
-
- io.vertx.reactivex.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.
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 is designed to be reused between requests.
NOTE: This class has been automatically generated from theoriginal
non 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 Deprecated Methods Modifier and Type Method Description void
close()
Close the client.void
close(Handler<AsyncResult<Void>> handler)
Close the client.HttpClient
connectionHandler(Handler<HttpConnection> handler)
Deprecated.boolean
equals(Object o)
HttpClient
getDelegate()
int
hashCode()
boolean
isMetricsEnabled()
Whether the metrics are enabled for this measured objectstatic HttpClient
newInstance(HttpClient arg)
HttpClient
redirectHandler(io.reactivex.functions.Function<HttpClientResponse,io.reactivex.Single<RequestOptions>> handler)
Deprecated.HttpClient
redirectHandler(Function<HttpClientResponse,Future<RequestOptions>> handler)
Deprecated.void
request(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehost
andport
.void
request(HttpMethod method, int port, String host, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server at thehost
andport
.void
request(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port.void
request(HttpMethod method, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server at the default host and port.void
request(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehost
and default port.void
request(HttpMethod method, String host, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server at thehost
and default port.void
request(RequestOptions options)
Create an HTTP request to send to the server.void
request(RequestOptions options, Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server.io.reactivex.Completable
rxClose()
Close the client.io.reactivex.Single<HttpClientRequest>
rxRequest(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehost
andport
.io.reactivex.Single<HttpClientRequest>
rxRequest(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port.io.reactivex.Single<HttpClientRequest>
rxRequest(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehost
and default port.io.reactivex.Single<HttpClientRequest>
rxRequest(RequestOptions options)
Create an HTTP request to send to the server.io.reactivex.Single<Boolean>
rxUpdateSSLOptions(SSLOptions options)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).io.reactivex.Single<Boolean>
rxUpdateSSLOptions(SSLOptions options, boolean force)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).io.reactivex.Single<WebSocket>
rxWebSocket(int port, String host, String requestURI)
Deprecated.io.reactivex.Single<WebSocket>
rxWebSocket(WebSocketConnectOptions options)
Deprecated.io.reactivex.Single<WebSocket>
rxWebSocket(String requestURI)
Deprecated.io.reactivex.Single<WebSocket>
rxWebSocket(String host, String requestURI)
Deprecated.io.reactivex.Single<WebSocket>
rxWebSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)
Deprecated.String
toString()
void
updateSSLOptions(SSLOptions options)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).void
updateSSLOptions(SSLOptions options, boolean force)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).void
updateSSLOptions(SSLOptions options, boolean force, Handler<AsyncResult<Boolean>> handler)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).void
updateSSLOptions(SSLOptions options, Handler<AsyncResult<Boolean>> handler)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).void
webSocket(int port, String host, String requestURI)
Deprecated.void
webSocket(int port, String host, String requestURI, Handler<AsyncResult<WebSocket>> handler)
Deprecated.void
webSocket(WebSocketConnectOptions options)
Deprecated.void
webSocket(WebSocketConnectOptions options, Handler<AsyncResult<WebSocket>> handler)
Deprecated.void
webSocket(String requestURI)
Deprecated.void
webSocket(String requestURI, Handler<AsyncResult<WebSocket>> handler)
Deprecated.void
webSocket(String host, String requestURI)
Deprecated.void
webSocket(String host, String requestURI, Handler<AsyncResult<WebSocket>> handler)
Deprecated.void
webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)
Deprecated.void
webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols, Handler<AsyncResult<WebSocket>> handler)
Deprecated.
-
-
-
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:
getDelegate
in interfaceMeasured
-
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 void request(RequestOptions options, Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server. Thehandler
is called when the request is ready to be sent.- Parameters:
options
- the request optionshandler
- the handler called when the request is ready to be sent
-
request
public void request(RequestOptions options)
Create an HTTP request to send to the server. Thehandler
is called when the request is ready to be sent.- Parameters:
options
- the request options
-
rxRequest
public io.reactivex.Single<HttpClientRequest> rxRequest(RequestOptions options)
Create an HTTP request to send to the server. Thehandler
is called when the request is ready to be sent.- Parameters:
options
- the request options- Returns:
-
request
public void request(HttpMethod method, int port, String host, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server at thehost
andport
. Thehandler
is called when the request is ready to be sent.- Parameters:
method
- the HTTP methodport
- the porthost
- the hostrequestURI
- the relative URIhandler
- the handler called when the request is ready to be sent
-
request
public void request(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehost
andport
. Thehandler
is called when the request is ready to be sent.- Parameters:
method
- the HTTP methodport
- the porthost
- the hostrequestURI
- the relative URI
-
rxRequest
public io.reactivex.Single<HttpClientRequest> rxRequest(HttpMethod method, int port, String host, String requestURI)
Create an HTTP request to send to the server at thehost
andport
. Thehandler
is called when the request is ready to be sent.- Parameters:
method
- the HTTP methodport
- the porthost
- the hostrequestURI
- the relative URI- Returns:
-
request
public void request(HttpMethod method, String host, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server at thehost
and default port. Thehandler
is called when the request is ready to be sent.- Parameters:
method
- the HTTP methodhost
- the hostrequestURI
- the relative URIhandler
- the handler called when the request is ready to be sent
-
request
public void request(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehost
and default port. Thehandler
is called when the request is ready to be sent.- Parameters:
method
- the HTTP methodhost
- the hostrequestURI
- the relative URI
-
rxRequest
public io.reactivex.Single<HttpClientRequest> rxRequest(HttpMethod method, String host, String requestURI)
Create an HTTP request to send to the server at thehost
and default port. Thehandler
is called when the request is ready to be sent.- Parameters:
method
- the HTTP methodhost
- the hostrequestURI
- the relative URI- Returns:
-
request
public void request(HttpMethod method, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server at the default host and port. Thehandler
is called when the request is ready to be sent.- Parameters:
method
- the HTTP methodrequestURI
- the relative URIhandler
- the handler called when the request is ready to be sent
-
request
public void request(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port. Thehandler
is called when the request is ready to be sent.- Parameters:
method
- the HTTP methodrequestURI
- the relative URI
-
rxRequest
public io.reactivex.Single<HttpClientRequest> rxRequest(HttpMethod method, String requestURI)
Create an HTTP request to send to the server at the default host and port. Thehandler
is called when the request is ready to be sent.- Parameters:
method
- the HTTP methodrequestURI
- the relative URI- Returns:
-
webSocket
@Deprecated public void webSocket(int port, String host, String requestURI, Handler<AsyncResult<WebSocket>> handler)
Deprecated.Connect a WebSocket to the specified port, host and relative request URI- Parameters:
port
- the porthost
- the hostrequestURI
- the relative URIhandler
- handler that will be called with the WebSocket when connected
-
webSocket
@Deprecated public void webSocket(int port, String host, String requestURI)
Deprecated.Connect a WebSocket to the specified port, host and relative request URI- Parameters:
port
- the porthost
- the hostrequestURI
- the relative URI
-
rxWebSocket
@Deprecated public io.reactivex.Single<WebSocket> rxWebSocket(int port, String host, String requestURI)
Deprecated.Connect a WebSocket to the specified port, host and relative request URI- Parameters:
port
- the porthost
- the hostrequestURI
- the relative URI- Returns:
-
webSocket
@Deprecated public void webSocket(String host, String requestURI, Handler<AsyncResult<WebSocket>> handler)
Deprecated.Connect a WebSocket to the host and relative request URI and default port- Parameters:
host
- the hostrequestURI
- the relative URIhandler
- handler that will be called with the WebSocket when connected
-
webSocket
@Deprecated public void webSocket(String host, String requestURI)
Deprecated.Connect a WebSocket to the host and relative request URI and default port- Parameters:
host
- the hostrequestURI
- the relative URI
-
rxWebSocket
@Deprecated public io.reactivex.Single<WebSocket> rxWebSocket(String host, String requestURI)
Deprecated.Connect a WebSocket to the host and relative request URI and default port- Parameters:
host
- the hostrequestURI
- the relative URI- Returns:
-
webSocket
@Deprecated public void webSocket(String requestURI, Handler<AsyncResult<WebSocket>> handler)
Deprecated.Connect a WebSocket at the relative request URI using the default host and port- Parameters:
requestURI
- the relative URIhandler
- handler that will be called with the WebSocket when connected
-
webSocket
@Deprecated public void webSocket(String requestURI)
Deprecated.Connect a WebSocket at the relative request URI using the default host and port- Parameters:
requestURI
- the relative URI
-
rxWebSocket
@Deprecated public io.reactivex.Single<WebSocket> rxWebSocket(String requestURI)
Deprecated.Connect a WebSocket at the relative request URI using the default host and port- Parameters:
requestURI
- the relative URI- Returns:
-
webSocket
@Deprecated public void webSocket(WebSocketConnectOptions options, Handler<AsyncResult<WebSocket>> handler)
Deprecated.Connect a WebSocket with the specified options.- Parameters:
options
- the request optionshandler
-
-
webSocket
@Deprecated public void webSocket(WebSocketConnectOptions options)
Deprecated.Connect a WebSocket with the specified options.- Parameters:
options
- the request options
-
rxWebSocket
@Deprecated public io.reactivex.Single<WebSocket> rxWebSocket(WebSocketConnectOptions options)
Deprecated.Connect a WebSocket with the specified options.- Parameters:
options
- the request options- Returns:
-
webSocketAbs
@Deprecated public void webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols, Handler<AsyncResult<WebSocket>> handler)
Deprecated.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 usehandler
- handler that will be called if WebSocket connection fails
-
webSocketAbs
@Deprecated public void webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)
Deprecated.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
-
rxWebSocketAbs
@Deprecated public io.reactivex.Single<WebSocket> rxWebSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)
Deprecated.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 void updateSSLOptions(SSLOptions options, Handler<AsyncResult<Boolean>> handler)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).- Parameters:
options
- the new SSL optionshandler
- the update handler
-
updateSSLOptions
public void updateSSLOptions(SSLOptions options)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).- Parameters:
options
- the new SSL options
-
rxUpdateSSLOptions
public io.reactivex.Single<Boolean> rxUpdateSSLOptions(SSLOptions options)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).- Parameters:
options
- the new SSL options- Returns:
-
updateSSLOptions
public void updateSSLOptions(SSLOptions options, boolean force, Handler<AsyncResult<Boolean>> handler)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).- Parameters:
options
- the new SSL optionsforce
- force the update when options are equalshandler
- the update handler
-
updateSSLOptions
public void updateSSLOptions(SSLOptions options, boolean force)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).- Parameters:
options
- the new SSL optionsforce
- force the update when options are equals
-
rxUpdateSSLOptions
public io.reactivex.Single<Boolean> rxUpdateSSLOptions(SSLOptions options, boolean force)
LikeupdateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update happened (or has failed).- Parameters:
options
- the new SSL optionsforce
- force the update when options are equals- Returns:
-
connectionHandler
@Deprecated public HttpClient connectionHandler(Handler<HttpConnection> handler)
Deprecated.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
@Deprecated public HttpClient redirectHandler(Function<HttpClientResponse,Future<RequestOptions>> handler)
Deprecated.Set a redirect handler for the http client.The redirect handler is called when a
3xx
response is received and the request is configured to follow redirects withHttpClientRequest.setFollowRedirects(boolean)
.The redirect handler is passed the
HttpClientResponse
, it can return anHttpClientRequest
ornull
.- when null is returned, the original response is processed by the original request response handler
- when a new
Future
is returned, the client will send this new request
The handler must return a
Future
unsent 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
-
redirectHandler
@Deprecated public HttpClient redirectHandler(io.reactivex.functions.Function<HttpClientResponse,io.reactivex.Single<RequestOptions>> handler)
Deprecated.Set a redirect handler for the http client.The redirect handler is called when a
3xx
response is received and the request is configured to follow redirects withHttpClientRequest.setFollowRedirects(boolean)
.The redirect handler is passed the
HttpClientResponse
, it can return anHttpClientRequest
ornull
.- when null is returned, the original response is processed by the original request response handler
- when a new
Future
is returned, the client will send this new request
The handler must return a
Future
unsent 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 void close(Handler<AsyncResult<Void>> handler)
Close the client. Closing will close down any pooled connections. Clients should always be closed after use.- Parameters:
handler
-
-
close
public void close()
Close the client. Closing will close down any pooled connections. Clients should always be closed after use.
-
rxClose
public io.reactivex.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)
-
-