Class 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 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 HttpHeadersCustomizers, 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 HttpHeadersCustomizers, 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.