An asynchronous HTTP client.
It allows you to make requests to HTTP servers, and a single client can make requests to any server.
It also allows you to open WebSockets to servers.
The client can also pool HTTP connections.
For pooling to occur, keep-alive must be true on the HttpClientOptions (default is true). In this case connections will be pooled and re-used if there are pending HTTP requests waiting to get a connection, otherwise they will be closed.
This gives the benefits of keep alive when the client is loaded but means we don't keep connections hanging around unnecessarily when there would be no benefits anyway.
The client also supports pipe-lining of requests. Pipe-lining means another request is sent on the same connection before the response from the preceeding one has returned. Pipe-lining is not appropriate for all requests.
To enable pipe-lining, it must be enabled on the HttpClientOptions (default is false).
When pipe-lining is enabled the connection will be automatically closed when all in-flight responses have returned and there are no outstanding pending requests to write.
The client is designed to be reused between requests.
Anything
HttpClient
Basic
Identifiable
Object
Anything
no subtypes hierarchy
Initializer |
HttpClient(HttpClient unknown) |
Inherited Attributes |
Attributes inherited from: Object hash , string |
Methods | |
close | shared default void close() Close the client. Closing will close down any pooled connections. Clients should always be closed after use. |
delete | shared default HttpClientRequest delete(String requestURI) Create an HTTP DELETE request to send to the server at the default host and port. Parameters:
|
delete | shared default HttpClientRequest delete(String host, String requestURI) Create an HTTP DELETE request to send to the server at the specified host and default port. Parameters:
|
delete | shared default HttpClientRequest delete(String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP DELETE request to send to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
delete | shared default HttpClientRequest delete(Integer port, String host, String requestURI) Create an HTTP DELETE request to send to the server at the specified host and port. Parameters:
|
delete | shared default HttpClientRequest delete(String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP DELETE request to send to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
delete | shared default HttpClientRequest delete(Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP DELETE request to send to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
deleteAbs | shared default HttpClientRequest deleteAbs(String absoluteURI) Create an HTTP DELETE request to send to the server using an absolute URI Parameters:
|
deleteAbs | shared default HttpClientRequest deleteAbs(String absoluteURI, Anything(HttpClientResponse) responseHandler) Create an HTTP DELETE request to send to the server using an absolute URI, specifying a response handler to receive the response Parameters:
|
get | shared default HttpClientRequest get(String requestURI) Create an HTTP GET request to send to the server at the default host and port. Parameters:
|
get | shared default HttpClientRequest get(String host, String requestURI) Create an HTTP GET request to send to the server at the specified host and default port. Parameters:
|
get | shared default HttpClientRequest get(String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP GET request to send to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
get | shared default HttpClientRequest get(Integer port, String host, String requestURI) Create an HTTP GET request to send to the server at the specified host and port. Parameters:
|
get | shared default HttpClientRequest get(String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP GET request to send to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
get | shared default HttpClientRequest get(Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP GET request to send to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
getAbs | shared default HttpClientRequest getAbs(String absoluteURI) Create an HTTP GET request to send to the server using an absolute URI Parameters:
|
getAbs | shared default HttpClientRequest getAbs(String absoluteURI, Anything(HttpClientResponse) responseHandler) Create an HTTP GET request to send to the server using an absolute URI, specifying a response handler to receive the response Parameters:
|
getNow | shared default HttpClient getNow(String requestURI, Anything(HttpClientResponse) responseHandler) Sends an HTTP GET request to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
getNow | shared default HttpClient getNow(String host, String requestURI, Anything(HttpClientResponse) responseHandler) Sends an HTTP GET request to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
getNow | shared default HttpClient getNow(Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Sends an HTTP GET request to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
head | shared default HttpClientRequest head(String requestURI) Create an HTTP HEAD request to send to the server at the default host and port. Parameters:
|
head | shared default HttpClientRequest head(String host, String requestURI) Create an HTTP HEAD request to send to the server at the specified host and default port. Parameters:
|
head | shared default HttpClientRequest head(String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP HEAD request to send to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
head | shared default HttpClientRequest head(Integer port, String host, String requestURI) Create an HTTP HEAD request to send to the server at the specified host and port. Parameters:
|
head | shared default HttpClientRequest head(String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP HEAD request to send to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
head | shared default HttpClientRequest head(Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP HEAD request to send to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
headAbs | shared default HttpClientRequest headAbs(String absoluteURI) Create an HTTP HEAD request to send to the server using an absolute URI Parameters:
|
headAbs | shared default HttpClientRequest headAbs(String absoluteURI, Anything(HttpClientResponse) responseHandler) Create an HTTP HEAD request to send to the server using an absolute URI, specifying a response handler to receive the response Parameters:
|
headNow | shared default HttpClient headNow(String requestURI, Anything(HttpClientResponse) responseHandler) Sends an HTTP HEAD request to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
headNow | shared default HttpClient headNow(String host, String requestURI, Anything(HttpClientResponse) responseHandler) Sends an HTTP HEAD request to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
headNow | shared default HttpClient headNow(Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Sends an HTTP HEAD request to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
isMetricsEnabled | shared actual default Boolean isMetricsEnabled() Whether the metrics are enabled for this measured object Refines Measured.isMetricsEnabled |
options | shared default HttpClientRequest options(String requestURI) Create an HTTP OPTIONS request to send to the server at the default host and port. Parameters:
|
options | shared default HttpClientRequest options(String host, String requestURI) Create an HTTP OPTIONS request to send to the server at the specified host and default port. Parameters:
|
options | shared default HttpClientRequest options(String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP OPTIONS request to send to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
options | shared default HttpClientRequest options(Integer port, String host, String requestURI) Create an HTTP OPTIONS request to send to the server at the specified host and port. Parameters:
|
options | shared default HttpClientRequest options(String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP OPTIONS request to send to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
options | shared default HttpClientRequest options(Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP OPTIONS request to send to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
optionsAbs | shared default HttpClientRequest optionsAbs(String absoluteURI) Create an HTTP OPTIONS request to send to the server using an absolute URI Parameters:
|
optionsAbs | shared default HttpClientRequest optionsAbs(String absoluteURI, Anything(HttpClientResponse) responseHandler) Create an HTTP OPTIONS request to send to the server using an absolute URI, specifying a response handler to receive the response Parameters:
|
optionsNow | shared default HttpClient optionsNow(String requestURI, Anything(HttpClientResponse) responseHandler) Sends an HTTP OPTIONS request to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
optionsNow | shared default HttpClient optionsNow(String host, String requestURI, Anything(HttpClientResponse) responseHandler) Sends an HTTP OPTIONS request to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
optionsNow | shared default HttpClient optionsNow(Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Sends an HTTP OPTIONS request to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
post | shared default HttpClientRequest post(String requestURI) Create an HTTP POST request to send to the server at the default host and port. Parameters:
|
post | shared default HttpClientRequest post(String host, String requestURI) Create an HTTP POST request to send to the server at the specified host and default port. Parameters:
|
post | shared default HttpClientRequest post(String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP POST request to send to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
post | shared default HttpClientRequest post(Integer port, String host, String requestURI) Create an HTTP POST request to send to the server at the specified host and port. Parameters:
|
post | shared default HttpClientRequest post(String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP POST request to send to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
post | shared default HttpClientRequest post(Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP POST request to send to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
postAbs | shared default HttpClientRequest postAbs(String absoluteURI) Create an HTTP POST request to send to the server using an absolute URI Parameters:
|
postAbs | shared default HttpClientRequest postAbs(String absoluteURI, Anything(HttpClientResponse) responseHandler) Create an HTTP POST request to send to the server using an absolute URI, specifying a response handler to receive the response Parameters:
|
put | shared default HttpClientRequest put(String requestURI) Create an HTTP PUT request to send to the server at the default host and port. Parameters:
|
put | shared default HttpClientRequest put(String host, String requestURI) Create an HTTP PUT request to send to the server at the specified host and default port. Parameters:
|
put | shared default HttpClientRequest put(String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP PUT request to send to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
put | shared default HttpClientRequest put(Integer port, String host, String requestURI) Create an HTTP PUT request to send to the server at the specified host and port. Parameters:
|
put | shared default HttpClientRequest put(String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP PUT request to send to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
put | shared default HttpClientRequest put(Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP PUT request to send to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
putAbs | shared default HttpClientRequest putAbs(String absoluteURI) Create an HTTP PUT request to send to the server using an absolute URI Parameters:
|
putAbs | shared default HttpClientRequest putAbs(String absoluteURI, Anything(HttpClientResponse) responseHandler) Create an HTTP PUT request to send to the server using an absolute URI, specifying a response handler to receive the response Parameters:
|
request | shared default HttpClientRequest request(HttpMethod method, String requestURI) Create an HTTP request to send to the server at the default host and port. Parameters:
|
request | shared default HttpClientRequest request(HttpMethod method, String host, String requestURI) Create an HTTP request to send to the server at the specified host and default port. Parameters:
|
request | shared default HttpClientRequest request(HttpMethod method, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP request to send to the server at the default host and port, specifying a response handler to receive the response Parameters:
|
request | shared default HttpClientRequest request(HttpMethod method, Integer port, String host, String requestURI) Create an HTTP request to send to the server at the specified host and port. Parameters:
|
request | shared default HttpClientRequest request(HttpMethod method, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP request to send to the server at the specified host and default port, specifying a response handler to receive the response Parameters:
|
request | shared default HttpClientRequest request(HttpMethod method, Integer port, String host, String requestURI, Anything(HttpClientResponse) responseHandler) Create an HTTP request to send to the server at the specified host and port, specifying a response handler to receive the response Parameters:
|
requestAbs | shared default HttpClientRequest requestAbs(HttpMethod method, String absoluteURI) Create an HTTP request to send to the server using an absolute URI Parameters:
|
requestAbs | shared default HttpClientRequest requestAbs(HttpMethod method, String absoluteURI, Anything(HttpClientResponse) responseHandler) Create an HTTP request to send to the server using an absolute URI, specifying a response handler to receive the response Parameters:
|
websocket | shared default HttpClient websocket(String requestURI, Anything(WebSocket) wsConnect) Connect a WebSocket at the relative request URI using the default host and port Parameters:
|
websocket | shared default HttpClient websocket(String host, String requestURI, Anything(WebSocket) wsConnect) Connect a WebSocket to the host and relative request URI and default port Parameters:
|
websocket | shared default HttpClient websocket(String requestURI, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket at the relative request URI using the default host and port Parameters:
|
websocket | shared default HttpClient websocket(String requestURI, MultiMap headers, Anything(WebSocket) wsConnect) Connect a WebSocket at the relative request URI using the default host and port and the specified headers Parameters:
|
websocket | shared default HttpClient websocket(Integer port, String host, String requestURI, Anything(WebSocket) wsConnect) Connect a WebSocket to the specified port, host and relative request URI Parameters:
|
websocket | shared default HttpClient websocket(String host, String requestURI, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket to the host and relative request URI and default port Parameters:
|
websocket | shared default HttpClient websocket(String host, String requestURI, MultiMap headers, Anything(WebSocket) wsConnect) Connect a WebSocket to the specified host,relative request UR, and default port and with the specified headers Parameters:
|
websocket | shared default HttpClient websocket(String requestURI, MultiMap headers, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket at the relative request URI using the default host and port and the specified headers Parameters:
|
websocket | shared default HttpClient websocket(String requestURI, MultiMap headers, WebsocketVersion version, Anything(WebSocket) wsConnect) Connect a WebSocket at the relative request URI using the default host and port, the specified headers and the specified version of WebSockets Parameters:
|
websocket | shared default HttpClient websocket(Integer port, String host, String requestURI, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket to the specified port, host and relative request URI Parameters:
|
websocket | shared default HttpClient websocket(Integer port, String host, String requestURI, MultiMap headers, Anything(WebSocket) wsConnect) Connect a WebSocket to the specified port, host and relative request URI, and with the specified headers Parameters:
|
websocket | shared default HttpClient websocket(String host, String requestURI, MultiMap headers, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket to the specified host,relative request UR, and default port and with the specified headers Parameters:
|
websocket | shared default HttpClient websocket(String host, String requestURI, MultiMap headers, WebsocketVersion version, Anything(WebSocket) wsConnect) Connect a WebSocket to the specified host, relative request URI and default port with the specified headers and using the specified version of WebSockets Parameters:
|
websocket | shared default HttpClient websocket(String requestURI, MultiMap headers, WebsocketVersion version, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket at the relative request URI using the default host and port, the specified headers and the specified version of WebSockets Parameters:
|
websocket | shared default HttpClient websocket(String requestURI, MultiMap headers, WebsocketVersion version, String subProtocols, Anything(WebSocket) wsConnect) Connect a WebSocket at the relative request URI using the default host and port, the specified headers, the specified version of WebSockets and the specified sub protocols Parameters:
|
websocket | shared default HttpClient websocket(Integer port, String host, String requestURI, MultiMap headers, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket to the specified port, host and relative request URI, and with the specified headers Parameters:
|
websocket | shared default HttpClient websocket(Integer port, String host, String requestURI, MultiMap headers, WebsocketVersion version, Anything(WebSocket) wsConnect) Connect a WebSocket to the specified port, host and relative request URI, with the specified headers and using the specified version of WebSockets Parameters:
|
websocket | shared default HttpClient websocket(String host, String requestURI, MultiMap headers, WebsocketVersion version, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket to the specified host, relative request URI and default port with the specified headers and using the specified version of WebSockets Parameters:
|
websocket | shared default HttpClient websocket(String host, String requestURI, MultiMap headers, WebsocketVersion version, String subProtocols, Anything(WebSocket) wsConnect) Connect a WebSocket to the specified host, relative request URI and default port, with the specified headers, using the specified version of WebSockets, and the specified websocket sub protocols Parameters:
|
websocket | shared default HttpClient websocket(String requestURI, MultiMap headers, WebsocketVersion version, String subProtocols, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket at the relative request URI using the default host and port, the specified headers, the specified version of WebSockets and the specified sub protocols Parameters:
|
websocket | shared default HttpClient websocket(Integer port, String host, String requestURI, MultiMap headers, WebsocketVersion version, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket to the specified port, host and relative request URI, with the specified headers and using the specified version of WebSockets Parameters:
|
websocket | shared default HttpClient websocket(Integer port, String host, String requestURI, MultiMap headers, WebsocketVersion version, String subProtocols, Anything(WebSocket) wsConnect) Connect a WebSocket to the specified port, host and relative request URI, with the specified headers, using the specified version of WebSockets, and the specified websocket sub protocols Parameters:
|
websocket | shared default HttpClient websocket(String host, String requestURI, MultiMap headers, WebsocketVersion version, String subProtocols, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket to the specified host, relative request URI and default port, with the specified headers, using the specified version of WebSockets, and the specified websocket sub protocols Parameters:
|
websocket | shared default HttpClient websocket(Integer port, String host, String requestURI, MultiMap headers, WebsocketVersion version, String subProtocols, Anything(WebSocket) wsConnect, Anything(Throwable) failureHandler) Connect a WebSocket to the specified port, host and relative request URI, with the specified headers, using the specified version of WebSockets, and the specified websocket sub protocols Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(String requestURI) Create a WebSocket stream at the relative request URI using the default host and port and the specified headers Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(String host, String requestURI) Create a WebSocket stream to the specified host, relative request URI and default port Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(String requestURI, MultiMap headers) Create a WebSocket stream at the relative request URI using the default host and port and the specified headers Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(Integer port, String host, String requestURI) Create a WebSocket stream to the specified port, host and relative request URI Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(String host, String requestURI, MultiMap headers) Create a WebSocket stream to the specified host, relative request URI and default port and with the specified headers Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(String requestURI, MultiMap headers, WebsocketVersion version) Create a WebSocket stream at the relative request URI using the default host and port, the specified headers and the specified version of WebSockets Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(Integer port, String host, String requestURI, MultiMap headers) Create a WebSocket stream to the specified port, host and relative request URI, and with the specified headers Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(String host, String requestURI, MultiMap headers, WebsocketVersion version) Create a WebSocket stream to the specified host, relative request URI and default port and with the specified headers and using the specified version of WebSockets Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(String requestURI, MultiMap headers, WebsocketVersion version, String subProtocols) Create a WebSocket stream at the relative request URI using the default host and port, the specified headers, the specified version of WebSockets and the specified sub protocols Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(Integer port, String host, String requestURI, MultiMap headers, WebsocketVersion version) Create a WebSocket stream to the specified port, host and relative request URI, with the specified headers and using the specified version of WebSockets Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(String host, String requestURI, MultiMap headers, WebsocketVersion version, String subProtocols) Create a WebSocket stream to the specified host, relative request URI and default port, with the specified headers, using the specified version of WebSockets, and the specified websocket sub protocols Parameters:
|
websocketStream | shared default WebSocketStream websocketStream(Integer port, String host, String requestURI, MultiMap headers, WebsocketVersion version, String subProtocols) Create a WebSocket stream to the specified port, host and relative request URI, with the specified headers, using the specified version of WebSockets, and the specified websocket sub protocols Parameters:
|
Inherited Methods |
Methods inherited from: Object equals |
Methods inherited from: Measured |