An HTTP client that maintains a pool of connections to a specific host, at a specific port. The client supports pipelining of requests.

If an instance is instantiated from an event loop then the handlers of the instance will always be called on that same event loop. If an instance is instantiated from some other arbitrary Java thread (i.e. when running embedded) then and event loop will be assigned to the instance and used when any of its handlers are called.

Instances of HttpClient are thread-safe.

By: Julien Viet

no subtypes hierarchy

Initializer
HttpClient(HttpClient delegate)
Attributes
connectTimeoutshared Integer connectTimeout

The connect timeout in milliseconds.

hostshared String host

The host

keepAliveshared Boolean keepAlive

Is the client keep alive?

maxPoolSizeshared Integer maxPoolSize
maxWebSocketFrameSizeshared Integer maxWebSocketFrameSize

Get the maximum websocket frame size in bytes.

portshared Integer port

The port

tryUserCompressionshared Boolean tryUserCompression

Returns true if the HttpClient should try to use compression.

verifyHostshared Boolean verifyHost

true if this client will validate the remote server's certificate hostname against the requested host

Inherited Attributes
Attributes inherited from: ClientBase
Attributes inherited from: NetworkBase
Attributes inherited from: Object
hash, string
Methods
closeshared void close()

Close the HTTP client. This will cause any pooled HTTP connections to be closed.

connectshared HttpClientRequest connect(String uri)

This method returns an HttpClientRequest instance which represents an HTTP CONNECT request with the specified uri.

connectWebsocketshared Promise<WebSocket> connectWebsocket(String uri, WebSocketVersion? wsVersion = null, {<String->String|{String+}>*}? headers = null, String[]? subprotocols = null)

Attempt to connect an HTML5 websocket to the specified URI

This version of the method allows you to specify the websockets version using the wsVersion parameter

You can also specify a set of headers to append to the upgrade request and specify the supported subprotocols.

The connect is done asynchronously, the returned promise is resolved with the websocket

Parameters:
  • wsVersion = null
  • headers = null
  • subprotocols = null
deleteshared HttpClientRequest delete(String uri)

This method returns an HttpClientRequest instance which represents an HTTP DELETE request with the specified uri.

exceptionHandlershared void exceptionHandler(void onError(Throwable t))
getshared HttpClientRequest get(String uri)

This method returns an HttpClientRequest instance which represents an HTTP GET request with the specified uri.

shared HttpClientRequest head(String uri)

This method returns an HttpClientRequest instance which represents an HTTP HEAD request with the specified uri.

optionsshared HttpClientRequest options(String uri)

This method returns an HttpClientRequest instance which represents an HTTP OPTIONS request with the specified uri.

patchshared HttpClientRequest patch(String uri)

This method returns an HttpClientRequest instance which represents an HTTP PATCH request with the specified uri.

postshared HttpClientRequest post(String uri)

This method returns an HttpClientRequest instance which represents an HTTP POST request with the specified uri.

putshared HttpClientRequest put(String uri)

This method returns an HttpClientRequest instance which represents an HTTP PUT request with the specified uri.

requestshared HttpClientRequest request(String method, String uri)

This method returns an HttpClientRequest instance which represents an HTTP request with the specified uri. The specific HTTP method (e.g. GET, POST, PUT etc) is specified using the parameter method.

When an HTTP response is received from the server the promise response is resolved with the response.

traceshared HttpClientRequest trace(String uri)

This method returns an HttpClientRequest instance which represents an HTTP TRACE request with the specified uri.

Inherited Methods
Methods inherited from: Object
equals