# Class DatabricksHttpClient

java.lang.Object
com.databricks.jdbc.dbclient.impl.http.DatabricksHttpClient

All Implemented Interfaces:
  `IDatabricksHttpClient`, `Closeable`, `AutoCloseable`

public class DatabricksHttpClient extends Object implements IDatabricksHttpClient, Closeable
Http client implementation to be used for executing http requests.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`org.apache.http.client.methods.CloseableHttpResponse`
`execute(org.apache.http.client.methods.HttpUriRequest request)`
Executes the given http request and returns the response
`org.apache.http.client.methods.CloseableHttpResponse`
`execute(org.apache.http.client.methods.HttpUriRequest request, boolean supportGzipEncoding)`
Executes the given http request and returns the response
`<T> Future<T>`
`executeAsync(org.apache.hc.core5.http.nio.AsyncRequestProducer requestProducer, org.apache.hc.core5.http.nio.AsyncResponseConsumer<T> responseConsumer, org.apache.hc.core5.concurrent.FutureCallback<T> callback)`
Executes the given http request asynchronously and returns the future

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

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

## Method Details

### execute

public org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpUriRequest request) throws DatabricksHttpException
Description copied from interface: `IDatabricksHttpClient`
Executes the given http request and returns the response

Specified by:
  `execute` in interface `IDatabricksHttpClient`
Parameters:
  `request` - underlying http request
Returns:
  http response
Throws:
  `DatabricksHttpException`

### execute

public org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpUriRequest request, boolean supportGzipEncoding) throws DatabricksHttpException
Description copied from interface: `IDatabricksHttpClient`
Executes the given http request and returns the response

Specified by:
  `execute` in interface `IDatabricksHttpClient`
Parameters:
  `request` - underlying http request
  `supportGzipEncoding` - whether to support gzip encoding header
Returns:
  http response
Throws:
  `DatabricksHttpException`

### executeAsync

public <T> Future<T> executeAsync(org.apache.hc.core5.http.nio.AsyncRequestProducer requestProducer, org.apache.hc.core5.http.nio.AsyncResponseConsumer<T> responseConsumer, org.apache.hc.core5.concurrent.FutureCallback<T> callback)
Executes the given http request asynchronously and returns the future

This method leverages the Apache Async HTTP client which uses non-blocking I/O, allowing for higher throughput and better resource utilization compared to blocking I/O. Instead of dedicating one thread per connection, it can handle multiple connections with a smaller thread pool, significantly reducing memory overhead and thread context switching.

Specified by:
  `executeAsync` in interface `IDatabricksHttpClient`
Type Parameters:
  `T` - type of the response
Parameters:
  `requestProducer` - request producer
  `responseConsumer` - response consumer
  `callback` - future callback
Returns:
  future

### close

public void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Throws:
  `IOException`