Top Fields Constructors Methods
io.vertx.core.http.impl

public Class SharedHttpClient

extends Object
implements HttpClientInternal
Class Inheritance
All Implemented Interfaces
io.vertx.core.http.impl.HttpClientInternal, io.vertx.core.http.HttpClient, io.vertx.core.metrics.Measured
Imports
io.vertx.core.AsyncResult, .Future, .Handler, .MultiMap, io.vertx.core.http.*, io.vertx.core.impl.CloseFuture, .ContextInternal, .VertxInternal, io.vertx.core.impl.future.PromiseInternal, io.vertx.core.net.SSLOptions, .SocketAddress, java.util.List, java.util.function.Function

Field Summary

Modifier and TypeField and Description
private final CloseFuture
private final HttpClientInternal
public static final String
private final VertxInternal

Constructor Summary

AccessConstructor and Description
public
SharedHttpClient(VertxInternal vertx, CloseFuture closeFuture, HttpClient delegate)

Method Summary

Modifier and TypeMethod and Description
public void
close(Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.http.HttpClient.close.

Close the client.

public Future<Void>
close()

Implements io.vertx.core.http.HttpClient.close.

Like close(Handler) but returns a Future of the asynchronous result

public Future<HttpClientConnection>
connect(SocketAddress
the server address
server
,
SocketAddress
the peer
peer
)

Implements io.vertx.core.http.impl.HttpClientInternal.connect.

Connect to a server.

public HttpClient
connectionHandler(Handler<HttpConnection> handler)

Implements io.vertx.core.http.HttpClient.connectionHandler.

Set a connection handler for the client.

public HttpClientOptions
public HttpClient
redirectHandler(Function<HttpClientResponse, Future<RequestOptions>>
the new redirect handler
handler
)

Implements io.vertx.core.http.HttpClient.redirectHandler.

Set a redirect handler for the http client.

public Function<HttpClientResponse, Future<RequestOptions>>
public void
request(RequestOptions
the request options
options
,
Handler<AsyncResult<HttpClientRequest>>
the handler called when the request is ready to be sent
handler
)

Implements io.vertx.core.http.HttpClient.request.

Create an HTTP request to send to the server.

public Future<HttpClientRequest>
request(RequestOptions options)

Implements io.vertx.core.http.HttpClient.request.

Like request(RequestOptions, Handler) but returns a Future of the asynchronous result

public void
request(HttpMethod
the HTTP method
method
,
int
the port
port
,
String
the host
host
,
String
the relative URI
requestURI
,
Handler<AsyncResult<HttpClientRequest>>
the handler called when the request is ready to be sent
handler
)

Implements io.vertx.core.http.HttpClient.request.

Create an HTTP request to send to the server at the host and port.

public Future<HttpClientRequest>
request(HttpMethod method, int port, String host, String requestURI)

Overrides default io.vertx.core.http.HttpClient.request.

Like request(HttpMethod, int, String, String, Handler) but returns a Future of the asynchronous result

public void
request(HttpMethod
the HTTP method
method
,
String
the host
host
,
String
the relative URI
requestURI
,
Handler<AsyncResult<HttpClientRequest>>
the handler called when the request is ready to be sent
handler
)

Implements io.vertx.core.http.HttpClient.request.

Create an HTTP request to send to the server at the host and default port.

public Future<HttpClientRequest>
request(HttpMethod method, String host, String requestURI)

Overrides default io.vertx.core.http.HttpClient.request.

Like request(HttpMethod, String, String, Handler) but returns a Future of the asynchronous result

public void
request(HttpMethod
the HTTP method
method
,
String
the relative URI
requestURI
,
Handler<AsyncResult<HttpClientRequest>>
the handler called when the request is ready to be sent
handler
)

Implements io.vertx.core.http.HttpClient.request.

Create an HTTP request to send to the server at the default host and port.

public Future<HttpClientRequest>
request(HttpMethod method, String requestURI)

Overrides default io.vertx.core.http.HttpClient.request.

Like request(HttpMethod, String, Handler) but returns a Future of the asynchronous result

public Future<Boolean>
updateSSLOptions(SSLOptions
the new SSL options
options
,
boolean
force the update when options are equals
force
)

Implements io.vertx.core.http.HttpClient.updateSSLOptions.

Update the client with new SSL options, the update happens if the options object is valid and different from the existing options object.

public VertxInternal
public void
webSocket(int
the port
port
,
String
the host
host
,
String
the relative URI
requestURI
,
Handler<AsyncResult<WebSocket>>
handler that will be called with the WebSocket when connected
handler
)

Implements io.vertx.core.http.HttpClient.webSocket.

Connect a WebSocket to the specified port, host and relative request URI

public Future<WebSocket>
webSocket(int port, String host, String requestURI)

Implements io.vertx.core.http.HttpClient.webSocket.

Like webSocket(int, String, String, Handler) but returns a Future of the asynchronous result

public void
webSocket(String
the host
host
,
String
the relative URI
requestURI
,
Handler<AsyncResult<WebSocket>>
handler that will be called with the WebSocket when connected
handler
)

Implements io.vertx.core.http.HttpClient.webSocket.

Connect a WebSocket to the host and relative request URI and default port

public Future<WebSocket>
webSocket(String host, String requestURI)

Implements io.vertx.core.http.HttpClient.webSocket.

Like webSocket(String, String, Handler) but returns a Future of the asynchronous result

public void
webSocket(String
the relative URI
requestURI
,
Handler<AsyncResult<WebSocket>>
handler that will be called with the WebSocket when connected
handler
)

Implements io.vertx.core.http.HttpClient.webSocket.

Connect a WebSocket at the relative request URI using the default host and port

public Future<WebSocket>
webSocket(String requestURI)

Implements io.vertx.core.http.HttpClient.webSocket.

Like webSocket(String, Handler) but returns a Future of the asynchronous result

public void
webSocket(WebSocketConnectOptions
the request options
options
,
Handler<AsyncResult<WebSocket>> handler)

Implements io.vertx.core.http.HttpClient.webSocket.

Connect a WebSocket with the specified options.

public Future<WebSocket>
webSocket(WebSocketConnectOptions options)

Implements io.vertx.core.http.HttpClient.webSocket.

Like webSocket(WebSocketConnectOptions, Handler) but returns a Future of the asynchronous result

public void
webSocketAbs(String
the absolute url
url
,
MultiMap
the headers
headers
,
WebsocketVersion
the WebSocket version
version
,
List<String>
the subprotocols to use
subProtocols
,
Handler<AsyncResult<WebSocket>>
handler that will be called if WebSocket connection fails
handler
)

Implements io.vertx.core.http.HttpClient.webSocketAbs.

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 Future<WebSocket>
webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)

Implements io.vertx.core.http.HttpClient.webSocketAbs.

Like webSocketAbs(String, MultiMap, WebsocketVersion, List, Handler) but returns a Future of the asynchronous result

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closeFutureback to summary
private final CloseFuture closeFuture
delegateback to summary
private final HttpClientInternal delegate
SHARED_MAP_NAMEback to summary
public static final String SHARED_MAP_NAME
vertxback to summary
private final VertxInternal vertx

Constructor Detail

SharedHttpClientback to summary
public SharedHttpClient(VertxInternal vertx, CloseFuture closeFuture, HttpClient delegate)

Method Detail

closeback to summary
public void close(Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.http.HttpClient.close.

Doc from io.vertx.core.http.HttpClient.close.

Close the client. Closing will close down any pooled connections. Clients should always be closed after use.

Annotations
@Override
closeback to summary
public Future<Void> close()

Implements io.vertx.core.http.HttpClient.close.

Doc from io.vertx.core.http.HttpClient.close.

Like close(Handler) but returns a Future of the asynchronous result

Annotations
@Override
connectback to summary
public Future<HttpClientConnection> connect(SocketAddress server, SocketAddress peer)

Implements io.vertx.core.http.impl.HttpClientInternal.connect.

Doc from io.vertx.core.http.impl.HttpClientInternal.connect.

Connect to a server.

Parameters
server:SocketAddress

the server address

peer:SocketAddress

the peer

Annotations
@Override
connectionHandlerback to summary
public HttpClient connectionHandler(Handler<HttpConnection> handler)

Implements io.vertx.core.http.HttpClient.connectionHandler.

Doc from io.vertx.core.http.HttpClient.connectionHandler.

Set a connection handler for the client. This handler is called when a new connection is established.

Returns:HttpClient

a reference to this, so the API can be used fluently

Annotations
@Override
optionsback to summary
public HttpClientOptions options()

Implements io.vertx.core.http.impl.HttpClientInternal.options.

Annotations
@Override
redirectHandlerback to summary
public HttpClient redirectHandler(Function<HttpClientResponse, Future<RequestOptions>> handler)

Implements io.vertx.core.http.HttpClient.redirectHandler.

Doc from io.vertx.core.http.HttpClient.redirectHandler.

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 with HttpClientRequest#setFollowRedirects(boolean).

The redirect handler is passed the HttpClientResponse, it can return an HttpClientRequest or null.

  • when null is returned, the original response is processed by the original request response handler
  • when a new Future<HttpClientRequest> is returned, the client will send this new request
The new request will get a copy of the previous request headers unless headers are set. In this case, the client assumes that the redirect handler exclusively managers the headers of the new request.

The handler must return a Future<HttpClientRequest> unsent so the client can further configure it and send it.

Parameters
handler:Function<HttpClientResponse, Future<RequestOptions>>

the new redirect handler

Returns:HttpClient

a reference to this, so the API can be used fluently

Annotations
@Override
redirectHandlerback to summary
public Function<HttpClientResponse, Future<RequestOptions>> redirectHandler()

Implements io.vertx.core.http.HttpClient.redirectHandler.

Returns:Function<HttpClientResponse, Future<RequestOptions>>

Doc from io.vertx.core.http.HttpClient.redirectHandler.

the current redirect handler.

Annotations
@Override
requestback to summary
public void request(RequestOptions options, Handler<AsyncResult<HttpClientRequest>> handler)

Implements io.vertx.core.http.HttpClient.request.

Doc from io.vertx.core.http.HttpClient.request.

Create an HTTP request to send to the server. The handler is called when the request is ready to be sent.

Parameters
options:RequestOptions

the request options

handler:Handler<AsyncResult<HttpClientRequest>>

the handler called when the request is ready to be sent

Annotations
@Override
requestback to summary
public Future<HttpClientRequest> request(RequestOptions options)

Implements io.vertx.core.http.HttpClient.request.

Doc from io.vertx.core.http.HttpClient.request.

Like request(RequestOptions, Handler) but returns a Future of the asynchronous result

Annotations
@Override
requestback to summary
public void request(HttpMethod method, int port, String host, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)

Implements io.vertx.core.http.HttpClient.request.

Doc from io.vertx.core.http.HttpClient.request.

Create an HTTP request to send to the server at the host and port. The handler is called when the request is ready to be sent.

Parameters
method:HttpMethod

the HTTP method

port:int

the port

host:String

the host

requestURI:String

the relative URI

handler:Handler<AsyncResult<HttpClientRequest>>

the handler called when the request is ready to be sent

Annotations
@Override
requestback to summary
public Future<HttpClientRequest> request(HttpMethod method, int port, String host, String requestURI)

Overrides default io.vertx.core.http.HttpClient.request.

Doc from io.vertx.core.http.HttpClient.request.

Like request(HttpMethod, int, String, String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
requestback to summary
public void request(HttpMethod method, String host, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)

Implements io.vertx.core.http.HttpClient.request.

Doc from io.vertx.core.http.HttpClient.request.

Create an HTTP request to send to the server at the host and default port. The handler is called when the request is ready to be sent.

Parameters
method:HttpMethod

the HTTP method

host:String

the host

requestURI:String

the relative URI

handler:Handler<AsyncResult<HttpClientRequest>>

the handler called when the request is ready to be sent

Annotations
@Override
requestback to summary
public Future<HttpClientRequest> request(HttpMethod method, String host, String requestURI)

Overrides default io.vertx.core.http.HttpClient.request.

Doc from io.vertx.core.http.HttpClient.request.

Like request(HttpMethod, String, String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
requestback to summary
public void request(HttpMethod method, String requestURI, Handler<AsyncResult<HttpClientRequest>> handler)

Implements io.vertx.core.http.HttpClient.request.

Doc from io.vertx.core.http.HttpClient.request.

Create an HTTP request to send to the server at the default host and port. The handler is called when the request is ready to be sent.

Parameters
method:HttpMethod

the HTTP method

requestURI:String

the relative URI

handler:Handler<AsyncResult<HttpClientRequest>>

the handler called when the request is ready to be sent

Annotations
@Override
requestback to summary
public Future<HttpClientRequest> request(HttpMethod method, String requestURI)

Overrides default io.vertx.core.http.HttpClient.request.

Doc from io.vertx.core.http.HttpClient.request.

Like request(HttpMethod, String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
updateSSLOptionsback to summary
public Future<Boolean> updateSSLOptions(SSLOptions options, boolean force)

Implements io.vertx.core.http.HttpClient.updateSSLOptions.

Doc from io.vertx.core.http.HttpClient.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 options object is compared using its equals 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, setting force to true forces the update.

The boolean succeeded future result indicates whether the update occurred.

Parameters
options:SSLOptions

the new SSL options

force:boolean

force the update when options are equals

Returns:Future<Boolean>

a future signaling the update success

Annotations
@Override
vertxback to summary
public VertxInternal vertx()

Implements io.vertx.core.http.impl.HttpClientInternal.vertx.

Returns:VertxInternal

Doc from io.vertx.core.http.impl.HttpClientInternal.vertx.

the vertx, for use in package related classes only.

Annotations
@Override
webSocketback to summary
public void webSocket(int port, String host, String requestURI, Handler<AsyncResult<WebSocket>> handler)

Implements io.vertx.core.http.HttpClient.webSocket.

Doc from io.vertx.core.http.HttpClient.webSocket.

Connect a WebSocket to the specified port, host and relative request URI

Parameters
port:int

the port

host:String

the host

requestURI:String

the relative URI

handler:Handler<AsyncResult<WebSocket>>

handler that will be called with the WebSocket when connected

Annotations
@Override
webSocketback to summary
public Future<WebSocket> webSocket(int port, String host, String requestURI)

Implements io.vertx.core.http.HttpClient.webSocket.

Doc from io.vertx.core.http.HttpClient.webSocket.

Like webSocket(int, String, String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
webSocketback to summary
public void webSocket(String host, String requestURI, Handler<AsyncResult<WebSocket>> handler)

Implements io.vertx.core.http.HttpClient.webSocket.

Doc from io.vertx.core.http.HttpClient.webSocket.

Connect a WebSocket to the host and relative request URI and default port

Parameters
host:String

the host

requestURI:String

the relative URI

handler:Handler<AsyncResult<WebSocket>>

handler that will be called with the WebSocket when connected

Annotations
@Override
webSocketback to summary
public Future<WebSocket> webSocket(String host, String requestURI)

Implements io.vertx.core.http.HttpClient.webSocket.

Doc from io.vertx.core.http.HttpClient.webSocket.

Like webSocket(String, String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
webSocketback to summary
public void webSocket(String requestURI, Handler<AsyncResult<WebSocket>> handler)

Implements io.vertx.core.http.HttpClient.webSocket.

Doc from io.vertx.core.http.HttpClient.webSocket.

Connect a WebSocket at the relative request URI using the default host and port

Parameters
requestURI:String

the relative URI

handler:Handler<AsyncResult<WebSocket>>

handler that will be called with the WebSocket when connected

Annotations
@Override
webSocketback to summary
public Future<WebSocket> webSocket(String requestURI)

Implements io.vertx.core.http.HttpClient.webSocket.

Doc from io.vertx.core.http.HttpClient.webSocket.

Like webSocket(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
webSocketback to summary
public void webSocket(WebSocketConnectOptions options, Handler<AsyncResult<WebSocket>> handler)

Implements io.vertx.core.http.HttpClient.webSocket.

Doc from io.vertx.core.http.HttpClient.webSocket.

Connect a WebSocket with the specified options.

Parameters
options:WebSocketConnectOptions

the request options

Annotations
@Override
webSocketback to summary
public Future<WebSocket> webSocket(WebSocketConnectOptions options)

Implements io.vertx.core.http.HttpClient.webSocket.

Doc from io.vertx.core.http.HttpClient.webSocket.

Like webSocket(WebSocketConnectOptions, Handler) but returns a Future of the asynchronous result

Annotations
@Override
webSocketAbsback to summary
public void webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols, Handler<AsyncResult<WebSocket>> handler)

Implements io.vertx.core.http.HttpClient.webSocketAbs.

Doc from io.vertx.core.http.HttpClient.webSocketAbs.

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:String

the absolute url

headers:MultiMap

the headers

version:WebsocketVersion

the WebSocket version

subProtocols:List<String>

the subprotocols to use

handler:Handler<AsyncResult<WebSocket>>

handler that will be called if WebSocket connection fails

Annotations
@Override
webSocketAbsback to summary
public Future<WebSocket> webSocketAbs(String url, MultiMap headers, WebsocketVersion version, List<String> subProtocols)

Implements io.vertx.core.http.HttpClient.webSocketAbs.

Doc from io.vertx.core.http.HttpClient.webSocketAbs.

Like webSocketAbs(String, MultiMap, WebsocketVersion, List, Handler) but returns a Future of the asynchronous result

Annotations
@Override