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'sHttpRequestInterceptor
andRequestHandler2
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 theHttpContext
set byAttributeEnhancingHttpRequestRetryHandler
to 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 void
beforeRequest(com.amazonaws.Request<?> request)
Processes an AWS HTTPRequest
before it is sent.void
process(org.apache.http.HttpRequest httpRequest, org.apache.http.protocol.HttpContext httpContext)
Processes an Apache HttpClientHttpRequest
before 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, IOException
Processes an Apache HttpClientHttpRequest
before it is sent. It iterates through registeredHttpHeadersCustomizer
s, 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:
process
in 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.HttpException
IOException
-
beforeRequest
public void beforeRequest(com.amazonaws.Request<?> request)
Processes an AWS HTTPRequest
before it is sent. It iterates through registeredHttpHeadersCustomizer
s, checks applicability, retrieves new headers, verifies against overriding driver headers, and adds them to the request. Ignores theinvokeOnce()
flag.- Specified by:
beforeRequest
in interfacecom.amazonaws.handlers.IRequestHandler2
- Overrides:
beforeRequest
in classcom.amazonaws.handlers.RequestHandler2
- Parameters:
request
- The AWS request to process.
-
-