new HttpClient()
An HTTP client that maintains a pool of connections to a specific host, at a specific port. The client supports pipelining of requests.
As well as HTTP requests, the client can act as a factory for
HTML5 websockets.
- Source:
Extends
- module:vertx/tcp_support~TCPSupport
- module:vertx/ssl_support~SSLSupport
- module:vertx/ssl_support~ClientSSLSupport
Methods
-
close()
-
Close the client
- Source:
-
connect(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP CONNECT request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the CONNECT on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
connectWebsocket(uri, handler)
-
Attempt to connect an HTML5 websocket to the specified URI. The connect is done asynchronously and the handler is called with a WebSocket on success.
Parameters:
Name Type Description uristring A relative URI where to connect the websocket on the host, e.g. /some/path handlerWebSocketHandler The handler to be called with the WebSocket - Source:
-
delete(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP DELETE request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the DELETE on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
exceptionHandler(handler) → {module:vertx/http.HttpClient}
-
Set the exception handler.
Parameters:
Name Type Description handlerHandler The handler which is called on an exception - Source:
Returns:
-
get(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP GET request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the GET on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
getNow(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This is a quick version of the get method where you do not want to do anything with the request before sing. With this method the request is immediately sent. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the GET on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
head(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP HEAD request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the HEAD on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
host(host) → {string|module:vertx/http.HttpClient}
-
Get or set the host name or ip address that the client will attempt to connect to on the server on
Parameters:
Name Type Argument Description hoststring <optional>
The host name or IP address. - Source:
Returns:
- Type
- string | module:vertx/http.HttpClient
-
keepAlive(keepAlive) → {boolean|module:vertx/http.HttpClient}
-
Get or set if the client use keep alive. If
keepAliveistruethen, after the request has ended the connection will be returned to the pool where it can be used by another request. In this manner, many HTTP requests can be pipe-lined over an HTTP connection. Keep alive connections will not be closed until theclose()method is invoked.If
keepAliveisfalsethen a new connection will be created for each request and it won't ever go in the pool, and the connection will closed after the response has been received. Even with no keep alive, the client will not allow more thangetMaxPoolSize()connections to be created at any one time.If
keepAliveisundefinedreturns the current keep alive status of this client.Parameters:
Name Type Argument Description keepAliveboolean <optional>
- Source:
Returns:
- Type
- boolean | module:vertx/http.HttpClient
-
keyStorePassword(password) → {boolean|Object}
-
Get or set the current keystore password for this object.
Parameters:
Name Type Argument Description passwordstring <optional>
If provided, sets the keystore password - Inherited From:
- Source:
Returns:
the current password, orthis.- Type
- boolean | Object
-
keyStorePath(path) → {boolean|Object}
-
Get or set the current keystore path for this object.
Parameters:
Name Type Argument Description pathstring <optional>
If provided, sets the keystore path - Inherited From:
- Source:
Returns:
the current path, orthis.- Type
- boolean | Object
-
maxPoolSize(size) → {number|module:vertx/http.HttpClient}
-
Get or set the maxium number of connections this client will pool
Parameters:
Name Type Argument Description sizenumber <optional>
the maximum number of connection - Source:
Returns:
- Type
- number | module:vertx/http.HttpClient
-
maxWebSocketFrameSize(size)
-
Set or get the maximum frame size for websocket connections exposed over the SockJS bridge with this HTTPClient
Parameters:
Name Type Argument Description sizenumber <optional>
The frame size in bytes - Source:
-
options(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP OPTIONS request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the OPTIONS on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
patch(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP PATCH request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the PATCH on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
port(port) → {number|module:vertx/http.HttpClient}
-
Get or set the port that the client will attempt to connect to on the server on. The default value is 80
Parameters:
Name Type Argument Description portnumber <optional>
The port to connect on. - Source:
Returns:
- Type
- number | module:vertx/http.HttpClient
-
post(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP POST request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the POST on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
put(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP PUT request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the PUT on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
receiveBufferSize(size) → {number|Object}
-
Set or get the receive buffer size
Parameters:
Name Type Argument Description sizenumber <optional>
If provided, set the value; if not, returns the current value. - Inherited From:
- Source:
Returns:
the value or this- Type
- number | Object
-
request(method, uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description methodstring The HTTP method which is used for the request uristring A relative URI where to perform the PUT on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
reuseAddress(reuse) → {boolean|Object}
-
Set or get the TCP reuse address value
Parameters:
Name Type Argument Description reuseboolean <optional>
If provided, set the value; if not, returns the current value. - Inherited From:
- Source:
Returns:
the value or this- Type
- boolean | Object
-
sendBufferSize(size) → {number|Object}
-
Set or get the send buffer size
Parameters:
Name Type Argument Description sizenumber <optional>
If provided, set the value; if not, returns the current value. - Inherited From:
- Source:
Returns:
the value or this- Type
- number | Object
-
soLinger(linger) → {boolean|Object}
-
Set or get the TCP so linger value
Parameters:
Name Type Argument Description lingerboolean <optional>
If provided, set the value; if not, returns the current value. - Inherited From:
- Source:
Returns:
the value or this- Type
- boolean | Object
-
ssl(ssl) → {boolean|Object}
-
Get or set the current SSL support for this object.
Parameters:
Name Type Argument Description sslboolean <optional>
If provided, sets whether this object supports SSL - Inherited From:
- Source:
Returns:
the current status, orthis.- Type
- boolean | Object
-
tcpKeepAlive(keepAlive) → {boolean|Object}
-
Set or get the TCP keep-alive value
Parameters:
Name Type Argument Description keepAliveboolean <optional>
If provided, set the value; if not, returns the current value. - Inherited From:
- Source:
Returns:
the value or this- Type
- boolean | Object
-
tcpNoDelay(nodelay) → {boolean|Object}
-
Set or get the TCP no delay value.
Parameters:
Name Type Argument Description nodelayboolean <optional>
If provided, set the value; if not, returns the current value. - Inherited From:
- Source:
Returns:
the value or this- Type
- boolean | Object
-
trace(uri, handler) → {module:vertx/http.HttpClientRequest}
-
This method returns an request which represents an HTTP TRACE request with the specified uri. When an HTTP response is received from the server the handler is called passing in the response.
Parameters:
Name Type Description uristring A relative URI where to perform the TRACE on the server. handlerResponseHandler The handler to be called - Source:
Returns:
-
trafficClass(class) → {number|Object}
-
Set or get the TCP traffic class
Parameters:
Name Type Argument Description classnumber <optional>
If provided, set the value; if not, returns the current value. - Inherited From:
- Source:
Returns:
the value or this- Type
- number | Object
-
trustAll(all) → {boolean|Object}
-
Get or set the trustAll SSL attribute
Parameters:
Name Type Argument Description allboolean <optional>
If provided, sets the trustAll attribute - Inherited From:
- Source:
Returns:
the current trustAll status, orthis- Type
- boolean | Object
-
trustStorePassword(password) → {boolean|Object}
-
Get or set the current trust store password for this object.
Parameters:
Name Type Argument Description passwordstring <optional>
If provided, sets the trust store password - Inherited From:
- Source:
Returns:
the current password, orthis.- Type
- boolean | Object
-
trustStorePath(path) → {boolean|Object}
-
Get or set the current trust store path for this object.
Parameters:
Name Type Argument Description pathstring <optional>
If provided, sets the trust store path - Inherited From:
- Source:
Returns:
the current path, orthis.- Type
- boolean | Object
-
tryUseCompression(shouldTry) → {boolean|module:vertx/http.HttpClient}
-
Set or get whether the client should try to use compression
Parameters:
Name Type Argument Description shouldTryboolean <optional>
Whether the client should try to use compression - Source:
Returns:
Whether compression is tried or self- Type
- boolean | module:vertx/http.HttpClient
-
usePooledBuffers(use) → {boolean|Object}
-
Set or get if vertx should use pooled buffers for performance reasons. Doing so will give the best throughput but may need a bit higher memory footprint.
Parameters:
Name Type Argument Description useboolean <optional>
If provided, set the value; if not, returns the current value. - Inherited From:
- Source:
Returns:
the value or this- Type
- boolean | Object
-
verifyHost(verify) → {boolean|module:vertx/http.HttpClient}
-
Get or set if the host should be verified. If set then the client will try to validate the remote server's certificate hostname against the requested host. Should default to 'true'. This method should only be used in SSL mode
Parameters:
Name Type Description verifyboolean whether or not to verify hosts - Source:
Returns:
- Type
- boolean | module:vertx/http.HttpClient