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'sHttpRequestInterceptorandRequestHandler2to 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
HttpHeadersCustomizerimplementations. 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_ATTRIBUTEattribute in theHttpContextset byAttributeEnhancingHttpRequestRetryHandlerto honor theinvokeOnce()contract of the customizer.- See Also:
HttpHeadersCustomizer
-
-
Constructor Summary
Constructors Constructor Description HeaderCustomizerHttpRequestInterceptor(List<HttpHeadersCustomizer> headersCustomizers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeforeRequest(com.amazonaws.Request<?> request)Processes an AWS HTTPRequestbefore it is sent.voidprocess(org.apache.http.HttpRequest httpRequest, org.apache.http.protocol.HttpContext httpContext)Processes an Apache HttpClientHttpRequestbefore it is sent.
-
-
-
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, IOExceptionProcesses an Apache HttpClientHttpRequestbefore it is sent. It iterates through registeredHttpHeadersCustomizers, checks applicability, retrieves new headers, verifies against overriding driver headers, and adds them to the request. Handles theinvokeOnce()flag based on the "execution-count" attribute in theHttpContext.- Specified by:
processin interfaceorg.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.HttpExceptionIOException
-
beforeRequest
public void beforeRequest(com.amazonaws.Request<?> request)
Processes an AWS HTTPRequestbefore it is sent. It iterates through registeredHttpHeadersCustomizers, checks applicability, retrieves new headers, verifies against overriding driver headers, and adds them to the request. Ignores theinvokeOnce()flag.- Specified by:
beforeRequestin interfacecom.amazonaws.handlers.IRequestHandler2- Overrides:
beforeRequestin classcom.amazonaws.handlers.RequestHandler2- Parameters:
request- The AWS request to process.
-
-