Package net.snowflake.client.core

## Class HeaderCustomizerHttpRequestInterceptor

- java.lang.Object
- - com.amazonaws.handlers.RequestHandler2
  - - net.snowflake.client.core.HeaderCustomizerHttpRequestInterceptor

All Implemented Interfaces:
  `com.amazonaws.handlers.IRequestHandler2`, `org.apache.http.HttpRequestInterceptor`

    @SnowflakeJdbcInternalApi
    public class HeaderCustomizerHttpRequestInterceptor
    extends com.amazonaws.handlers.RequestHandler2
    implements org.apache.http.HttpRequestInterceptor

Implements Apache HttpClient's `HttpRequestInterceptor` and `RequestHandler2` to provide a mechanism for adding custom HTTP headers to outgoing requests made by the Snowflake JDBC driver.

This class iterates through a list of user-provided `HttpHeadersCustomizer` implementations. For each customizer, it checks if it applies to the current request. If it does, it retrieves new headers from the customizer and adds them to the request, ensuring that existing driver-set headers are not overridden.

For Apache HttpClient, retry detection is handled by checking the `AttributeEnhancingHttpRequestRetryHandler.EXECUTION_COUNT_ATTRIBUTE` attribute in the `HttpContext` set by `AttributeEnhancingHttpRequestRetryHandler` to honor the `invokeOnce()` contract of the customizer.

See Also:
  `HttpHeadersCustomizer`

### Constructor Summary

Constructors
`HeaderCustomizerHttpRequestInterceptor​(List<HttpHeadersCustomizer> headersCustomizers)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `beforeRequest​(com.amazonaws.Request<?> request)` Processes an AWS HTTP `Request` before it is sent.
`void` `process​(org.apache.http.HttpRequest httpRequest, org.apache.http.protocol.HttpContext httpContext)` Processes an Apache HttpClient `HttpRequest` before it is sent.

### Methods inherited from class com.amazonaws.handlers.RequestHandler2

`adapt, afterAttempt, afterError, afterResponse, beforeAttempt, beforeExecution, beforeMarshalling, beforeUnmarshalling`

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

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

### Constructor Detail

#### HeaderCustomizerHttpRequestInterceptor

    public HeaderCustomizerHttpRequestInterceptor​(List<HttpHeadersCustomizer> headersCustomizers)

### Method Detail

#### process

    public void process​(org.apache.http.HttpRequest httpRequest,
                        org.apache.http.protocol.HttpContext httpContext)
                 throws org.apache.http.HttpException,
                        IOException

Processes an Apache HttpClient `HttpRequest` before it is sent. It iterates through registered `HttpHeadersCustomizer`s, checks applicability, retrieves new headers, verifies against overriding driver headers, and adds them to the request. Handles the `invokeOnce()` flag based on the "execution-count" attribute in the `HttpContext`.

Specified by:
  `process` in interface `org.apache.http.HttpRequestInterceptor`
Parameters:
  `httpRequest` - The HTTP request to process.
  `httpContext` - The context for the HTTP request execution, used to retrieve retry count.
Throws:
  `org.apache.http.HttpException`
  `IOException`

#### beforeRequest

    public void beforeRequest​(com.amazonaws.Request<?> request)

Processes an AWS HTTP `Request` before it is sent. It iterates through registered `HttpHeadersCustomizer`s, checks applicability, retrieves new headers, verifies against overriding driver headers, and adds them to the request. Ignores the `invokeOnce()` flag.

Specified by:
  `beforeRequest` in interface `com.amazonaws.handlers.IRequestHandler2`
Overrides:
  `beforeRequest` in class `com.amazonaws.handlers.RequestHandler2`
Parameters:
  `request` - The AWS request to process.