public class HttpClientImpl extends Object implements HttpClient, MetricsProvider, Closeable
| Constructor and Description |
|---|
HttpClientImpl(VertxInternal vertx,
HttpClientOptions options,
CloseFuture closeFuture) |
| Modifier and Type | Method and Description |
|---|---|
Future<Void> |
close()
Like
HttpClient.close(Handler) but returns a Future of the asynchronous result |
void |
close(Handler<AsyncResult<Void>> handler)
Close the client.
|
void |
close(Promise<Void> completion)
Close this resource, the
completion promise must be notified when the operation has completed. |
Future<HttpClientConnection> |
connect(SocketAddress server)
Connect to a server.
|
Future<HttpClientConnection> |
connect(SocketAddress server,
SocketAddress peer)
Connect to a server.
|
HttpClient |
connectionHandler(Handler<HttpConnection> handler)
Set a connection handler for the client.
|
protected void |
finalize() |
Metrics |
getMetrics()
Returns the metrics implementation.
|
HttpClientOptions |
getOptions() |
VertxInternal |
getVertx() |
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
Function<HttpClientResponse,Future<RequestOptions>> |
redirectHandler() |
HttpClient |
redirectHandler(Function<HttpClientResponse,Future<RequestOptions>> handler)
Set a redirect handler for the http client.
|
Future<HttpClientRequest> |
request(HttpMethod method,
int port,
String host,
String requestURI)
Like
HttpClient.request(HttpMethod, int, String, String, Handler) but returns a Future of the asynchronous result |
void |
request(HttpMethod method,
int port,
String host,
String requestURI,
Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server at the
host and port. |
Future<HttpClientRequest> |
request(HttpMethod method,
String requestURI)
Like
HttpClient.request(HttpMethod, String, Handler) but returns a Future of the asynchronous result |
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.
|
Future<HttpClientRequest> |
request(HttpMethod method,
String host,
String requestURI)
Like
HttpClient.request(HttpMethod, String, String, Handler) but returns a Future of the asynchronous result |
void |
request(HttpMethod method,
String host,
String requestURI,
Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server at the
host and default port. |
Future<HttpClientRequest> |
request(RequestOptions options)
Like
HttpClient.request(RequestOptions, Handler) but returns a Future of the asynchronous result |
void |
request(RequestOptions options,
Handler<AsyncResult<HttpClientRequest>> handler)
Create an HTTP request to send to the server.
|
Future<WebSocket> |
webSocket(int port,
String host,
String requestURI)
Like
HttpClient.webSocket(int, String, String, Handler) but returns a Future of the asynchronous result |
void |
webSocket(int port,
String host,
String requestURI,
Handler<AsyncResult<WebSocket>> handler)
Connect a WebSocket to the specified port, host and relative request URI
|
Future<WebSocket> |
webSocket(String requestURI)
Like
HttpClient.webSocket(String, Handler) but returns a Future of the asynchronous result |
void |
webSocket(String requestURI,
Handler<AsyncResult<WebSocket>> handler)
Connect a WebSocket at the relative request URI using the default host and port
|
Future<WebSocket> |
webSocket(String host,
String requestURI)
Like
HttpClient.webSocket(String, String, Handler) but returns a Future of the asynchronous result |
void |
webSocket(String host,
String requestURI,
Handler<AsyncResult<WebSocket>> handler)
Connect a WebSocket to the host and relative request URI and default port
|
Future<WebSocket> |
webSocket(WebSocketConnectOptions options)
Like
HttpClient.webSocket(WebSocketConnectOptions, Handler) but returns a Future of the asynchronous result |
void |
webSocket(WebSocketConnectOptions connectOptions,
Handler<AsyncResult<WebSocket>> handler)
Connect a WebSocket with the specified options.
|
Future<WebSocket> |
webSocketAbs(String url,
MultiMap headers,
WebsocketVersion version,
List<String> subProtocols)
Like
HttpClient.webSocketAbs(String, MultiMap, WebsocketVersion, List, Handler) but returns a Future of the asynchronous result |
void |
webSocketAbs(String url,
MultiMap headers,
WebsocketVersion version,
List<String> subProtocols,
Handler<AsyncResult<WebSocket>> handler)
Connect a WebSocket with the specified absolute url, with the specified headers, using
the specified version of WebSockets, and the specified WebSocket sub protocols.
|
public HttpClientImpl(VertxInternal vertx, HttpClientOptions options, CloseFuture closeFuture)
public Future<HttpClientConnection> connect(SocketAddress server)
public Future<HttpClientConnection> connect(SocketAddress server, SocketAddress peer)
public void webSocket(WebSocketConnectOptions connectOptions, Handler<AsyncResult<WebSocket>> handler)
HttpClientwebSocket in interface HttpClientconnectOptions - the request optionspublic Future<WebSocket> webSocket(int port, String host, String requestURI)
HttpClientHttpClient.webSocket(int, String, String, Handler) but returns a Future of the asynchronous resultwebSocket in interface HttpClientpublic Future<WebSocket> webSocket(String host, String requestURI)
HttpClientHttpClient.webSocket(String, String, Handler) but returns a Future of the asynchronous resultwebSocket in interface HttpClientpublic Future<WebSocket> webSocket(String requestURI)
HttpClientHttpClient.webSocket(String, Handler) but returns a Future of the asynchronous resultwebSocket in interface HttpClientpublic Future<WebSocket> webSocket(WebSocketConnectOptions options)
HttpClientHttpClient.webSocket(WebSocketConnectOptions, Handler) but returns a Future of the asynchronous resultwebSocket in interface HttpClientpublic Future<WebSocket> webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)
HttpClientHttpClient.webSocketAbs(String, MultiMap, WebsocketVersion, List, Handler) but returns a Future of the asynchronous resultwebSocketAbs in interface HttpClientpublic void webSocket(int port,
String host,
String requestURI,
Handler<AsyncResult<WebSocket>> handler)
HttpClientwebSocket in interface HttpClientport - the porthost - the hostrequestURI - the relative URIhandler - handler that will be called with the WebSocket when connectedpublic void webSocket(String host, String requestURI, Handler<AsyncResult<WebSocket>> handler)
HttpClientwebSocket in interface HttpClienthost - the hostrequestURI - the relative URIhandler - handler that will be called with the WebSocket when connectedpublic void webSocket(String requestURI, Handler<AsyncResult<WebSocket>> handler)
HttpClientwebSocket in interface HttpClientrequestURI - the relative URIhandler - handler that will be called with the WebSocket when connectedpublic void webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols, Handler<AsyncResult<WebSocket>> handler)
HttpClientwebSocketAbs in interface HttpClienturl - the absolute urlheaders - the headersversion - the WebSocket versionsubProtocols - the subprotocols to usehandler - handler that will be called if WebSocket connection failspublic void request(RequestOptions options, Handler<AsyncResult<HttpClientRequest>> handler)
HttpClienthandler
is called when the request is ready to be sent.request in interface HttpClientoptions - the request optionshandler - the handler called when the request is ready to be sentpublic Future<HttpClientRequest> request(RequestOptions options)
HttpClientHttpClient.request(RequestOptions, Handler) but returns a Future of the asynchronous resultrequest in interface HttpClientpublic void request(HttpMethod method, int port, String host, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)
HttpClienthost and port. The handler
is called when the request is ready to be sent.request in interface HttpClientmethod - the HTTP methodport - the porthost - the hostrequestURI - the relative URIhandler - the handler called when the request is ready to be sentpublic Future<HttpClientRequest> request(HttpMethod method, int port, String host, String requestURI)
HttpClientHttpClient.request(HttpMethod, int, String, String, Handler) but returns a Future of the asynchronous resultrequest in interface HttpClientpublic void request(HttpMethod method, String host, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)
HttpClienthost and default port. The handler
is called when the request is ready to be sent.request in interface HttpClientmethod - the HTTP methodhost - the hostrequestURI - the relative URIhandler - the handler called when the request is ready to be sentpublic Future<HttpClientRequest> request(HttpMethod method, String host, String requestURI)
HttpClientHttpClient.request(HttpMethod, String, String, Handler) but returns a Future of the asynchronous resultrequest in interface HttpClientpublic void request(HttpMethod method, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)
HttpClienthandler
is called when the request is ready to be sent.request in interface HttpClientmethod - the HTTP methodrequestURI - the relative URIhandler - the handler called when the request is ready to be sentpublic Future<HttpClientRequest> request(HttpMethod method, String requestURI)
HttpClientHttpClient.request(HttpMethod, String, Handler) but returns a Future of the asynchronous resultrequest in interface HttpClientpublic void close(Promise<Void> completion)
Closeablecompletion promise must be notified when the operation has completed.public void close(Handler<AsyncResult<Void>> handler)
HttpClientclose in interface HttpClientpublic Future<Void> close()
HttpClientHttpClient.close(Handler) but returns a Future of the asynchronous resultclose in interface HttpClientpublic boolean isMetricsEnabled()
MeasuredisMetricsEnabled in interface Measuredtrue if metrics are enabledpublic Metrics getMetrics()
MetricsProvidergetMetrics in interface MetricsProviderpublic HttpClient connectionHandler(Handler<HttpConnection> handler)
HttpClientconnectionHandler in interface HttpClientpublic HttpClient redirectHandler(Function<HttpClientResponse,Future<RequestOptions>> handler)
HttpClient
The redirect handler is called when a 3xx response is received and the request is configured to
follow redirects with HttpClientRequest.setFollowRedirects(boolean).
The redirect handler is passed the HttpClientResponse, it can return an HttpClientRequest or null.
Future<HttpClientRequest> is returned, the client will send this new request
The handler must return a Future<HttpClientRequest> unsent so the client can further configure it and send it.
redirectHandler in interface HttpClienthandler - the new redirect handlerpublic Function<HttpClientResponse,Future<RequestOptions>> redirectHandler()
redirectHandler in interface HttpClientpublic HttpClientOptions getOptions()
public VertxInternal getVertx()
Copyright © 2021. All rights reserved.