org.vertx.java.core.http.impl

## Class DefaultHttpClient

- java.lang.Object
- - org.vertx.java.core.http.impl.DefaultHttpClient

All Implemented Interfaces:
  HttpClient

    public class DefaultHttpClient
    extends java.lang.Object
    implements HttpClient

### Constructor Summary

Constructors
Constructor and Description
`DefaultHttpClient(VertxInternal vertx)`

### Method Summary

Methods
`void` `close()` Close the HTTP client.
`HttpClientRequest` `connect(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP CONNECT request with the specified `uri`.
`void` `connectWebsocket(java.lang.String uri, Handler<WebSocket> wsConnect)` Attempt to connect an HTML5 websocket to the specified URI
`void` `connectWebsocket(java.lang.String uri, WebSocketVersion wsVersion, Handler<WebSocket> wsConnect)` Attempt to connect an HTML5 websocket to the specified URI
`HttpClientRequest` `delete(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP DELETE request with the specified `uri`.
`void` `exceptionHandler(Handler<java.lang.Exception> handler)` Set an exception handler
`HttpClientRequest` `get(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP GET request with the specified `uri`.
`java.lang.Integer` `getBossThreads()`
`java.lang.Long` `getConnectTimeout()`
`java.lang.String` `getKeyStorePassword()`
`java.lang.String` `getKeyStorePath()`
`int` `getMaxPoolSize()` Returns the maximum number of connections in the pool
`void` `getNow(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This is a quick version of the `HttpClient.get(String, org.vertx.java.core.Handler)` method where you do not want to do anything with the request before sending.
`void` `getNow(java.lang.String uri, java.util.Map<java.lang.String,? extends java.lang.Object> headers, Handler<HttpClientResponse> responseHandler)` This method works in the same manner as `HttpClient.getNow(String, org.vertx.java.core.Handler)`, except that it allows you specify a set of `headers` that will be sent with the request.
`java.lang.Integer` `getReceiveBufferSize()`
`java.lang.Integer` `getSendBufferSize()`
`java.lang.Integer` `getTrafficClass()`
`java.lang.String` `getTrustStorePassword()`
`java.lang.String` `getTrustStorePath()`
`HttpClientRequest` `head(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP HEAD request with the specified `uri`.
`java.lang.Boolean` `isReuseAddress()`
`java.lang.Boolean` `isSoLinger()`
`boolean` `isSSL()`
`java.lang.Boolean` `isTCPKeepAlive()`
`java.lang.Boolean` `isTCPNoDelay()`
`boolean` `isTrustAll()`
`HttpClientRequest` `options(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP OPTIONS request with the specified `uri`.
`HttpClientRequest` `patch(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP PATCH request with the specified `uri`.
`HttpClientRequest` `post(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP POST request with the specified `uri`.
`HttpClientRequest` `put(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP PUT request with the specified `uri`.
`HttpClientRequest` `request(java.lang.String method, java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP request with the specified `uri`.
`DefaultHttpClient` `setBossThreads(int threads)` Set the number of boss threads to use.
`DefaultHttpClient` `setConnectTimeout(long timeout)` Set the connect timeout in milliseconds.
`DefaultHttpClient` `setHost(java.lang.String host)` Set the host that the client will attempt to connect to the server on to `host`.
`DefaultHttpClient` `setKeepAlive(boolean keepAlive)` If `keepAlive` is `true` then, after the request has ended the connection will be returned to the pool where it can be used by another request.
`DefaultHttpClient` `setKeyStorePassword(java.lang.String pwd)` Set the password for the SSL key store.
`DefaultHttpClient` `setKeyStorePath(java.lang.String path)` Set the path to the SSL key store.
`DefaultHttpClient` `setMaxPoolSize(int maxConnections)` Set the maximum pool size
`DefaultHttpClient` `setPort(int port)` Set the port that the client will attempt to connect to the server on to `port`.
`DefaultHttpClient` `setReceiveBufferSize(int size)` Set the TCP receive buffer size for connections created by this instance to `size` in bytes.
`DefaultHttpClient` `setReuseAddress(boolean reuse)` Set the TCP reuseAddress setting for connections created by this instance to `reuse`.
`DefaultHttpClient` `setSendBufferSize(int size)` Set the TCP send buffer size for connections created by this instance to `size` in bytes.
`DefaultHttpClient` `setSoLinger(boolean linger)` Set the TCP soLinger setting for connections created by this instance to `linger`.
`DefaultHttpClient` `setSSL(boolean ssl)` If `ssl` is `true`, this signifies that any connections will be SSL connections.
`DefaultHttpClient` `setTCPKeepAlive(boolean keepAlive)` Set the TCP keepAlive setting for connections created by this instance to `keepAlive`.
`DefaultHttpClient` `setTCPNoDelay(boolean tcpNoDelay)` If `tcpNoDelay` is set to `true` then Nagle's algorithm will turned off for the TCP connections created by this instance.
`DefaultHttpClient` `setTrafficClass(int trafficClass)` Set the TCP trafficClass setting for connections created by this instance to `trafficClass`.
`DefaultHttpClient` `setTrustAll(boolean trustAll)` If you want an SSL client to trust *all* server certificates rather than match them against those in its trust store, you can set this to true.
`DefaultHttpClient` `setTrustStorePassword(java.lang.String pwd)` Set the password for the SSL trust store.
`DefaultHttpClient` `setTrustStorePath(java.lang.String path)` Set the path to the SSL trust store.
`HttpClientRequest` `trace(java.lang.String uri, Handler<HttpClientResponse> responseHandler)` This method returns an `HttpClientRequest` instance which represents an HTTP TRACE request with the specified `uri`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DefaultHttpClient

    public DefaultHttpClient(VertxInternal vertx)

### Method Detail

#### exceptionHandler

    public void exceptionHandler(Handler<java.lang.Exception> handler)

Description copied from interface: `HttpClient`
Set an exception handler

Specified by:
  `exceptionHandler` in interface `HttpClient`

#### setMaxPoolSize

    public DefaultHttpClient setMaxPoolSize(int maxConnections)

Description copied from interface: `HttpClient`
Set the maximum pool size

The client will maintain up to `maxConnections` HTTP connections in an internal pool

Specified by:
  `setMaxPoolSize` in interface `HttpClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### getMaxPoolSize

    public int getMaxPoolSize()

Description copied from interface: `HttpClient`
Returns the maximum number of connections in the pool

Specified by:
  `getMaxPoolSize` in interface `HttpClient`

#### setKeepAlive

    public DefaultHttpClient setKeepAlive(boolean keepAlive)

Description copied from interface: `HttpClient`
If `keepAlive` is `true` then, 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 the `close()` method is invoked.

If `keepAlive` is `false` then a new connection will be created for each request and it won't ever go in the pool, the connection will closed after the response has been received. Even with no keep alive, the client will not allow more than `HttpClient.getMaxPoolSize()` connections to be created at any one time.

Specified by:
  `setKeepAlive` in interface `HttpClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setPort

    public DefaultHttpClient setPort(int port)

Description copied from interface: `HttpClient`
Set the port that the client will attempt to connect to the server on to `port`. The default value is `80`

Specified by:
  `setPort` in interface `HttpClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setHost

    public DefaultHttpClient setHost(java.lang.String host)

Description copied from interface: `HttpClient`
Set the host that the client will attempt to connect to the server on to `host`. The default value is `localhost`

Specified by:
  `setHost` in interface `HttpClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### connectWebsocket

    public void connectWebsocket(java.lang.String uri,
                        Handler<WebSocket> wsConnect)

Description copied from interface: `HttpClient`
Attempt to connect an HTML5 websocket to the specified URI

The connect is done asynchronously and `wsConnect` is called back with the websocket

Specified by:
  `connectWebsocket` in interface `HttpClient`

#### connectWebsocket

    public void connectWebsocket(java.lang.String uri,
                        WebSocketVersion wsVersion,
                        Handler<WebSocket> wsConnect)

Description copied from interface: `HttpClient`
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` The connect is done asynchronously and `wsConnect` is called back with the websocket

Specified by:
  `connectWebsocket` in interface `HttpClient`

#### getNow

    public void getNow(java.lang.String uri,
              Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This is a quick version of the `HttpClient.get(String, org.vertx.java.core.Handler)` method where you do not want to do anything with the request before sending.

Normally with any of the HTTP methods you create the request then when you are ready to send it you call `HttpClientRequest.end()` on it. With this method the request is immediately sent.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `getNow` in interface `HttpClient`

#### getNow

    public void getNow(java.lang.String uri,
              java.util.Map<java.lang.String,? extends java.lang.Object> headers,
              Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method works in the same manner as `HttpClient.getNow(String, org.vertx.java.core.Handler)`, except that it allows you specify a set of `headers` that will be sent with the request.

Specified by:
  `getNow` in interface `HttpClient`

#### options

    public HttpClientRequest options(java.lang.String uri,
                            Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method returns an `HttpClientRequest` instance which represents an HTTP OPTIONS request with the specified `uri`.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `options` in interface `HttpClient`

#### get

    public HttpClientRequest get(java.lang.String uri,
                        Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method returns an `HttpClientRequest` instance which represents an HTTP GET request with the specified `uri`.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `get` in interface `HttpClient`

#### head

    public HttpClientRequest head(java.lang.String uri,
                         Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method returns an `HttpClientRequest` instance which represents an HTTP HEAD request with the specified `uri`.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `head` in interface `HttpClient`

#### post

    public HttpClientRequest post(java.lang.String uri,
                         Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method returns an `HttpClientRequest` instance which represents an HTTP POST request with the specified `uri`.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `post` in interface `HttpClient`

#### put

    public HttpClientRequest put(java.lang.String uri,
                        Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method returns an `HttpClientRequest` instance which represents an HTTP PUT request with the specified `uri`.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `put` in interface `HttpClient`

#### delete

    public HttpClientRequest delete(java.lang.String uri,
                           Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method returns an `HttpClientRequest` instance which represents an HTTP DELETE request with the specified `uri`.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `delete` in interface `HttpClient`

#### trace

    public HttpClientRequest trace(java.lang.String uri,
                          Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method returns an `HttpClientRequest` instance which represents an HTTP TRACE request with the specified `uri`.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `trace` in interface `HttpClient`

#### connect

    public HttpClientRequest connect(java.lang.String uri,
                            Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method returns an `HttpClientRequest` instance which represents an HTTP CONNECT request with the specified `uri`.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `connect` in interface `HttpClient`

#### patch

    public HttpClientRequest patch(java.lang.String uri,
                          Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
This method returns an `HttpClientRequest` instance which represents an HTTP PATCH request with the specified `uri`.

When an HTTP response is received from the server the `responseHandler` is called passing in the response.

Specified by:
  `patch` in interface `HttpClient`

#### request

    public HttpClientRequest request(java.lang.String method,
                            java.lang.String uri,
                            Handler<HttpClientResponse> responseHandler)

Description copied from interface: `HttpClient`
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 `responseHandler` is called passing in the response.

Specified by:
  `request` in interface `HttpClient`

#### close

    public void close()

Description copied from interface: `HttpClient`
Close the HTTP client. This will cause any pooled HTTP connections to be closed.

Specified by:
  `close` in interface `HttpClient`

#### setSSL

    public DefaultHttpClient setSSL(boolean ssl)

Description copied from interface: `HttpClient`
If `ssl` is `true`, this signifies that any connections will be SSL connections.

Specified by:
  `setSSL` in interface `HttpClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setKeyStorePath

    public DefaultHttpClient setKeyStorePath(java.lang.String path)

Description copied from interface: `HttpClient`
Set the path to the SSL key store. This method should only be used in SSL mode, i.e. after `HttpClient.setSSL(boolean)` has been set to `true`.

The SSL key store is a standard Java Key Store, and will contain the client certificate. Client certificates are only required if the server requests client authentication.

Specified by:
  `setKeyStorePath` in interface `HttpClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setKeyStorePassword

    public DefaultHttpClient setKeyStorePassword(java.lang.String pwd)

Description copied from interface: `HttpClient`
Set the password for the SSL key store. This method should only be used in SSL mode, i.e. after `HttpClient.setSSL(boolean)` has been set to `true`.

Specified by:
  `setKeyStorePassword` in interface `HttpClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setTrustStorePath

    public DefaultHttpClient setTrustStorePath(java.lang.String path)

Description copied from interface: `HttpClient`
Set the path to the SSL trust store. This method should only be used in SSL mode, i.e. after `HttpClient.setSSL(boolean)` has been set to `true`.

The trust store is a standard Java Key Store, and should contain the certificates of any servers that the client trusts. If you wish the client to trust all server certificates you can use the `HttpClient.setTrustAll(boolean)` method.

Specified by:
  `setTrustStorePath` in interface `HttpClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setTrustStorePassword

    public DefaultHttpClient setTrustStorePassword(java.lang.String pwd)

Description copied from interface: `HttpClient`
Set the password for the SSL trust store. This method should only be used in SSL mode, i.e. after `HttpClient.setSSL(boolean)` has been set to `true`.

Specified by:
  `setTrustStorePassword` in interface `HttpClient`
Returns:
  A reference to this, so multiple invocations can be chained together.

#### setTrustAll

    public DefaultHttpClient setTrustAll(boolean trustAll)

Description copied from interface: `HttpClient`
If you want an SSL client to trust *all* server certificates rather than match them against those in its trust store, you can set this to true.

Use this with caution as you may be exposed to "main in the middle" attacks

Specified by:
  `setTrustAll` in interface `HttpClient`
Parameters:
  `trustAll` - Set to true if you want to trust all server certificates

#### setTCPNoDelay

    public DefaultHttpClient setTCPNoDelay(boolean tcpNoDelay)

Description copied from interface: `HttpClient`
If `tcpNoDelay` is set to `true` then Nagle's algorithm will turned off for the TCP connections created by this instance.

Specified by:
  `setTCPNoDelay` in interface `HttpClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setSendBufferSize

    public DefaultHttpClient setSendBufferSize(int size)

Description copied from interface: `HttpClient`
Set the TCP send buffer size for connections created by this instance to `size` in bytes.

Specified by:
  `setSendBufferSize` in interface `HttpClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setReceiveBufferSize

    public DefaultHttpClient setReceiveBufferSize(int size)

Description copied from interface: `HttpClient`
Set the TCP receive buffer size for connections created by this instance to `size` in bytes.

Specified by:
  `setReceiveBufferSize` in interface `HttpClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setTCPKeepAlive

    public DefaultHttpClient setTCPKeepAlive(boolean keepAlive)

Description copied from interface: `HttpClient`
Set the TCP keepAlive setting for connections created by this instance to `keepAlive`.

Specified by:
  `setTCPKeepAlive` in interface `HttpClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setReuseAddress

    public DefaultHttpClient setReuseAddress(boolean reuse)

Description copied from interface: `HttpClient`
Set the TCP reuseAddress setting for connections created by this instance to `reuse`.

Specified by:
  `setReuseAddress` in interface `HttpClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setSoLinger

    public DefaultHttpClient setSoLinger(boolean linger)

Description copied from interface: `HttpClient`
Set the TCP soLinger setting for connections created by this instance to `linger`.

Specified by:
  `setSoLinger` in interface `HttpClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setTrafficClass

    public DefaultHttpClient setTrafficClass(int trafficClass)

Description copied from interface: `HttpClient`
Set the TCP trafficClass setting for connections created by this instance to `trafficClass`.

Specified by:
  `setTrafficClass` in interface `HttpClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setConnectTimeout

    public DefaultHttpClient setConnectTimeout(long timeout)

Description copied from interface: `HttpClient`
Set the connect timeout in milliseconds.

Specified by:
  `setConnectTimeout` in interface `HttpClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### setBossThreads

    public DefaultHttpClient setBossThreads(int threads)

Description copied from interface: `HttpClient`
Set the number of boss threads to use. Boss threads are used to make connections.

Specified by:
  `setBossThreads` in interface `HttpClient`
Returns:
  a reference to this so multiple method calls can be chained together

#### isTCPNoDelay

    public java.lang.Boolean isTCPNoDelay()

Specified by:
  `isTCPNoDelay` in interface `HttpClient`
Returns:
  true if Nagle's algorithm is disabled.

#### getSendBufferSize

    public java.lang.Integer getSendBufferSize()

Specified by:
  `getSendBufferSize` in interface `HttpClient`
Returns:
  The TCP send buffer size

#### getReceiveBufferSize

    public java.lang.Integer getReceiveBufferSize()

Specified by:
  `getReceiveBufferSize` in interface `HttpClient`
Returns:
  The TCP receive buffer size

#### isTCPKeepAlive

    public java.lang.Boolean isTCPKeepAlive()

Specified by:
  `isTCPKeepAlive` in interface `HttpClient`
Returns:
  true if TCP keep alive is enabled

#### isReuseAddress

    public java.lang.Boolean isReuseAddress()

Specified by:
  `isReuseAddress` in interface `HttpClient`
Returns:
  The value of TCP reuse address

#### isSoLinger

    public java.lang.Boolean isSoLinger()

Specified by:
  `isSoLinger` in interface `HttpClient`
Returns:
  the value of TCP so linger

#### getTrafficClass

    public java.lang.Integer getTrafficClass()

Specified by:
  `getTrafficClass` in interface `HttpClient`
Returns:
  the value of TCP traffic class

#### getConnectTimeout

    public java.lang.Long getConnectTimeout()

Specified by:
  `getConnectTimeout` in interface `HttpClient`
Returns:
  The connect timeout in milliseconds

#### getBossThreads

    public java.lang.Integer getBossThreads()

Specified by:
  `getBossThreads` in interface `HttpClient`
Returns:
  The number of boss threads

#### isSSL

    public boolean isSSL()

Specified by:
  `isSSL` in interface `HttpClient`
Returns:
  true if this client will make SSL connections

#### isTrustAll

    public boolean isTrustAll()

Specified by:
  `isTrustAll` in interface `HttpClient`
Returns:
  true if this client will trust all server certificates.

#### getKeyStorePath

    public java.lang.String getKeyStorePath()

Specified by:
  `getKeyStorePath` in interface `HttpClient`
Returns:
  The path to the key store

#### getKeyStorePassword

    public java.lang.String getKeyStorePassword()

Specified by:
  `getKeyStorePassword` in interface `HttpClient`
Returns:
  The keystore password

#### getTrustStorePath

    public java.lang.String getTrustStorePath()

Specified by:
  `getTrustStorePath` in interface `HttpClient`
Returns:
  The trust store path

#### getTrustStorePassword

    public java.lang.String getTrustStorePassword()

Specified by:
  `getTrustStorePassword` in interface `HttpClient`
Returns:
  The trust store password