# Class: HttpClient

## vertx-js/http_client~ HttpClient

#### new HttpClient()

  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.

  Source:
    - http_client.js, line 41

### Methods

#### close()

  Close the client. Closing will close down any pooled connections. Clients should always be closed after use.
  Source:
    - http_client.js, line 641

#### delete(port, host, requestURI, responseHandler) → {HttpClientRequest}

  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:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 482

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### deleteAbs(absoluteURI, responseHandler) → {HttpClientRequest}

  Create an HTTP DELETE request to send to the server using an absolute URI, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absoluteURI` | string | the absolute URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 514

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### get(port, host, requestURI, responseHandler) → {HttpClientRequest}

  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:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 128

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### getAbs(absoluteURI, responseHandler) → {HttpClientRequest}

  Create an HTTP GET request to send to the server using an absolute URI, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absoluteURI` | string | the absolute URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 160

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### getNow(port, host, requestURI, responseHandler) → {HttpClient}

  Sends an HTTP GET request to the server at the specified host and port, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 182

  ##### Returns:

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

#### head(port, host, requestURI, responseHandler) → {HttpClientRequest}

  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:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 264

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### headAbs(absoluteURI, responseHandler) → {HttpClientRequest}

  Create an HTTP HEAD request to send to the server using an absolute URI, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absoluteURI` | string | the absolute URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 296

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### headNow(port, host, requestURI, responseHandler) → {HttpClient}

  Sends an HTTP HEAD request to the server at the specified host and port, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 318

  ##### Returns:

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

#### isMetricsEnabled() → {boolean}

  Whether the metrics are enabled for this measured object
  Source:
    - http_client.js, line 54

  ##### Returns:

  true if the metrics are enabled
  Type
    boolean

#### options(port, host, requestURI, responseHandler) → {HttpClientRequest}

  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:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 346

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### optionsAbs(absoluteURI, responseHandler) → {HttpClientRequest}

  Create an HTTP OPTIONS request to send to the server using an absolute URI, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absoluteURI` | string | the absolute URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 378

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### optionsNow(port, host, requestURI, responseHandler) → {HttpClient}

  Sends an HTTP OPTIONS request to the server at the specified host and port, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 400

  ##### Returns:

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

#### post(port, host, requestURI, responseHandler) → {HttpClientRequest}

  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:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 210

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### postAbs(absoluteURI, responseHandler) → {HttpClientRequest}

  Create an HTTP POST request to send to the server using an absolute URI, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absoluteURI` | string | the absolute URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 242

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### put(port, host, requestURI, responseHandler) → {HttpClientRequest}

  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:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 428

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### putAbs(absoluteURI, responseHandler) → {HttpClientRequest}

  Create an HTTP PUT request to send to the server using an absolute URI, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `absoluteURI` | string | the absolute URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 460

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### request(method, port, host, requestURI, responseHandler) → {HttpClientRequest}

  Create an HTTP request to send to the server at the specified host and port, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `method` | Object | the HTTP method
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 73

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### requestAbs(method, absoluteURI, responseHandler) → {HttpClientRequest}

  Create an HTTP request to send to the server using an absolute URI, specifying a response handler to receive the response

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `method` | Object | the HTTP method
  `absoluteURI` | string | the absolute URI
  `responseHandler` | function | the response handler

  Source:
    - http_client.js, line 106

  ##### Returns:

  an HTTP client request object
  Type
    HttpClientRequest

#### websocket(port, host, requestURI, headers, version, subProtocols, wsConnect) → {HttpClient}

  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:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `headers` | MultiMap | the headers
  `version` | Object | the websocket version
  `subProtocols` | string | the subprotocols to use
  `wsConnect` | function | handler that will be called with the websocket when connected

  Source:
    - http_client.js, line 539

  ##### Returns:

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

#### websocketStream(port, host, requestURI, headers, version, subProtocols) → {WebSocketStream}

  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:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port
  `host` | string | the host
  `requestURI` | string | the relative URI
  `headers` | MultiMap | the headers
  `version` | Object | the websocket version
  `subProtocols` | string | the subprotocols to use

  Source:
    - http_client.js, line 605

  ##### Returns:

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