org.apache.calcite.avatica.remote

## Class AvaticaCommonsHttpClientImpl

- java.lang.Object
- - org.apache.calcite.avatica.remote.AvaticaCommonsHttpClientImpl

All Implemented Interfaces:
  AvaticaHttpClient, TrustStoreConfigurable, UsernamePasswordAuthenticateable

    public class AvaticaCommonsHttpClientImpl
    extends Object
    implements AvaticaHttpClient, UsernamePasswordAuthenticateable, TrustStoreConfigurable

A common class to invoke HTTP requests against the Avatica server agnostic of the data being sent and received across the wire.

### Field Summary

Fields
`protected org.apache.http.impl.client.BasicAuthCache` `authCache`
`protected org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider>` `authRegistry`
`protected org.apache.http.impl.client.CloseableHttpClient` `client`
`protected org.apache.http.auth.UsernamePasswordCredentials` `credentials`
`protected org.apache.http.client.CredentialsProvider` `credentialsProvider`
`protected org.apache.http.HttpHost` `host`
`private static org.slf4j.Logger` `LOG`
`private static String` `MAX_POOLED_CONNECTION_PER_ROUTE_DEFAULT`
`private static String` `MAX_POOLED_CONNECTION_PER_ROUTE_KEY`
`private static String` `MAX_POOLED_CONNECTIONS_DEFAULT`
`private static String` `MAX_POOLED_CONNECTIONS_KEY`
`(package private) org.apache.http.impl.conn.PoolingHttpClientConnectionManager` `pool`
`protected File` `truststore`
`protected String` `truststorePassword`
`protected URI` `uri`

### Constructor Summary

Constructors
Constructor and Description
`AvaticaCommonsHttpClientImpl(URL url)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`(package private) org.apache.http.client.methods.CloseableHttpResponse` `execute(org.apache.http.client.methods.HttpPost post, org.apache.http.client.protocol.HttpClientContext context)`
`private void` `initializeClient()`
`byte[]` `send(byte[] request)` Sends a serialized request to the Avatica server.
`void` `setTrustStore(File truststore, String password)` Sets a truststore containing the collection of trust SSL/TLS server certificates to use for HTTPS calls and the password for that truststore.
`void` `setUsernamePassword(AuthenticationType authType, String username, String password)` Sets the username, password and method to be used for authentication.
`private static URI` `toURI(URL url)`

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

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

### Field Detail

#### LOG

    private static final org.slf4j.Logger LOG

#### MAX_POOLED_CONNECTION_PER_ROUTE_KEY

    private static final String MAX_POOLED_CONNECTION_PER_ROUTE_KEY

See Also:
  Constant Field Values

#### MAX_POOLED_CONNECTION_PER_ROUTE_DEFAULT

    private static final String MAX_POOLED_CONNECTION_PER_ROUTE_DEFAULT

See Also:
  Constant Field Values

#### MAX_POOLED_CONNECTIONS_KEY

    private static final String MAX_POOLED_CONNECTIONS_KEY

See Also:
  Constant Field Values

#### MAX_POOLED_CONNECTIONS_DEFAULT

    private static final String MAX_POOLED_CONNECTIONS_DEFAULT

See Also:
  Constant Field Values

#### host

    protected final org.apache.http.HttpHost host

#### uri

    protected final URI uri

#### authCache

    protected org.apache.http.impl.client.BasicAuthCache authCache

#### client

    protected org.apache.http.impl.client.CloseableHttpClient client

#### pool

    org.apache.http.impl.conn.PoolingHttpClientConnectionManager pool

#### credentials

    protected org.apache.http.auth.UsernamePasswordCredentials credentials

#### credentialsProvider

    protected org.apache.http.client.CredentialsProvider credentialsProvider

#### authRegistry

    protected org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authRegistry

#### truststore

    protected File truststore

#### truststorePassword

    protected String truststorePassword

### Constructor Detail

#### AvaticaCommonsHttpClientImpl

    public AvaticaCommonsHttpClientImpl(URL url)

### Method Detail

#### initializeClient

    private void initializeClient()

#### send

    public byte[] send(byte[] request)

Description copied from interface: `AvaticaHttpClient`
Sends a serialized request to the Avatica server.

Specified by:
  `send` in interface `AvaticaHttpClient`
Parameters:
  `request` - The serialized request.
Returns:
  The serialized response.

#### execute

    org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpPost post,
                                                                 org.apache.http.client.protocol.HttpClientContext context)
                                                          throws IOException,
                                                                 org.apache.http.client.ClientProtocolException

Throws:
  `IOException`
  `org.apache.http.client.ClientProtocolException`

#### setUsernamePassword

    public void setUsernamePassword(AuthenticationType authType,
                                    String username,
                                    String password)

Description copied from interface: `UsernamePasswordAuthenticateable`
Sets the username, password and method to be used for authentication.

Specified by:
  `setUsernamePassword` in interface `UsernamePasswordAuthenticateable`
Parameters:
  `authType` - Type of authentication
  `username` - Username
  `password` - Password

#### toURI

    private static URI toURI(URL url)
                      throws RuntimeException

Throws:
  `RuntimeException`

#### setTrustStore

    public void setTrustStore(File truststore,
                              String password)

Description copied from interface: `TrustStoreConfigurable`
Sets a truststore containing the collection of trust SSL/TLS server certificates to use for HTTPS calls and the password for that truststore.

Specified by:
  `setTrustStore` in interface `TrustStoreConfigurable`
Parameters:
  `truststore` - The truststore on the local filesystem
  `password` - The truststore's password