Top Description Methods
io.vertx.core.http

public Interface HttpClientBuilder

Known Direct Implementers
io.vertx.core.http.impl.HttpClientBuilderImpl
Annotations
@VertxGen
Imports
io.vertx.codegen.annotations.Fluent, .VertxGen, io.vertx.core.Future, .Handler, java.util.function.Function

A builder for HttpClient.
Author
Julien Viet

Method Summary

Modifier and TypeMethod and Description
public HttpClient

Returns:

the client as configured by this builder
build
()

Build and return the client.

public HttpClientBuilder

Returns:

a reference to this, so the API can be used fluently
with
(HttpClientOptions
the client options
options
)

Configure the client options.

public HttpClientBuilder

Returns:

a reference to this, so the API can be used fluently
with
(PoolOptions
the pool options
options
)

Configure the client with the given pool options.

public HttpClientBuilder

Returns:

a reference to this, so the API can be used fluently
withConnectHandler
(Handler<HttpConnection> handler)

Set a connection handler for the client.

public HttpClientBuilder

Returns:

a reference to this, so the API can be used fluently
withRedirectHandler
(Function<HttpClientResponse, Future<RequestOptions>>
the new redirect handler
handler
)

Set a redirect handler for the http client.

Method Detail

buildback to summary
public HttpClient build()

Build and return the client.

Returns:HttpClient

the client as configured by this builder

withback to summary
public HttpClientBuilder with(HttpClientOptions options)

Configure the client options.

Parameters
options:HttpClientOptions

the client options

Returns:HttpClientBuilder

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

Annotations
@Fluent
withback to summary
public HttpClientBuilder with(PoolOptions options)

Configure the client with the given pool options.

Parameters
options:PoolOptions

the pool options

Returns:HttpClientBuilder

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

Annotations
@Fluent
withConnectHandlerback to summary
public HttpClientBuilder withConnectHandler(Handler<HttpConnection> handler)

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

Returns:HttpClientBuilder

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

Annotations
@Fluent
withRedirectHandlerback to summary
public HttpClientBuilder withRedirectHandler(Function<HttpClientResponse, Future<RequestOptions>> handler)

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

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

Annotations
@Fluent