public class HttpUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
HttpUtil.HttpInputStream |
| Modifier and Type | Field and Description |
|---|---|
static Map<HttpClientSettingsKey,org.apache.http.impl.client.CloseableHttpClient> |
httpClient
The unique httpClient shared by all connections.
|
static String |
JDBC_MAX_CONNECTIONS_PER_ROUTE_PROPERTY |
static String |
JDBC_MAX_CONNECTIONS_PROPERTY |
static String |
JDBC_TTL |
| Constructor and Description |
|---|
HttpUtil() |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.http.impl.client.CloseableHttpClient |
buildHttpClient(HttpClientSettingsKey key,
File ocspCacheFile,
boolean downloadCompressed)
Build an Http client using our set of default.
|
static void |
closeExpiredAndIdleConnections() |
static String |
executeGeneralRequest(org.apache.http.client.methods.HttpRequestBase httpRequest,
int retryTimeout,
int authTimeout,
int socketTimeout,
int retryCount,
org.apache.http.impl.client.CloseableHttpClient httpClient)
Executes a HTTP request for Snowflake
|
static String |
executeGeneralRequest(org.apache.http.client.methods.HttpRequestBase httpRequest,
int retryTimeout,
int authTimeout,
int socketTimeout,
int retryCount,
HttpClientSettingsKey ocspAndProxyKey)
Executes a HTTP request for Snowflake.
|
static String |
executeRequest(org.apache.http.client.methods.HttpRequestBase httpRequest,
int retryTimeout,
int authTimeout,
int socketTimeout,
int retryCount,
int injectSocketTimeout,
AtomicBoolean canceling,
boolean includeRetryParameters,
boolean retryOnHTTP403,
HttpClientSettingsKey ocspAndProxyKey)
Executes a HTTP request for Snowflake.
|
static org.apache.http.client.config.RequestConfig |
getDefaultRequestConfigWithSocketAndConnectTimeout(int requestSocketAndConnectTimeout,
boolean withoutCookies)
Return a request configuration inheriting from the default request configuration of the shared
HttpClient with a different socket and connect timeout.
|
static org.apache.http.client.config.RequestConfig |
getDefaultRequestConfigWithSocketTimeout(int soTimeoutMs,
boolean withoutCookies)
Return a request configuration inheriting from the default request configuration of the shared
HttpClient with a different socket timeout.
|
static long |
getDownloadedConditionTimeoutInSeconds() |
static org.apache.http.impl.client.CloseableHttpClient |
getHttpClient(HttpClientSettingsKey ocspAndProxyKey)
Gets HttpClient with insecureMode false
|
static org.apache.http.impl.client.CloseableHttpClient |
getHttpClientWithoutDecompression(HttpClientSettingsKey ocspAndProxyKey)
Gets HttpClient with insecureMode false and disabling decompression
|
static org.apache.http.client.config.RequestConfig |
getRequestConfigWithoutCookies()
Return a request configuration inheriting from the default request configuration of the shared
HttpClient with the coopkie spec set to ignore.
|
static org.apache.http.impl.client.CloseableHttpClient |
initHttpClient(HttpClientSettingsKey key,
File ocspCacheFile)
Accessor for the HTTP client singleton.
|
static org.apache.http.impl.client.CloseableHttpClient |
initHttpClientWithoutDecompression(HttpClientSettingsKey key,
File ocspCacheFile)
Accessor for the HTTP client singleton.
|
static boolean |
isSocksProxyDisabled()
Returns whether the SOCKS proxy is disabled for this JVM
|
static void |
setProxyForAzure(HttpClientSettingsKey key,
com.microsoft.azure.storage.OperationContext opContext)
A static function to set Azure proxy params when there is a valid session
|
static void |
setProxyForS3(HttpClientSettingsKey key,
com.amazonaws.ClientConfiguration clientConfig)
A static function to set S3 proxy params when there is a valid session
|
static void |
setRequestConfig(org.apache.http.client.config.RequestConfig requestConfig) |
static void |
setSessionlessProxyForAzure(Properties proxyProperties,
com.microsoft.azure.storage.OperationContext opContext)
A static function to set Azure proxy params for sessionless connections using the proxy params
from the StageInfo
|
static void |
setSessionlessProxyForS3(Properties proxyProperties,
com.amazonaws.ClientConfiguration clientConfig)
A static function to set S3 proxy params for sessionless connections using the proxy params
from the StageInfo
|
static void |
setSocksProxyDisabled(boolean socksProxyDisabled)
Enables/disables use of the SOCKS proxy when creating sockets
|
static void |
updateRoutePlanner(HttpClientSettingsKey key) |
public static final String JDBC_TTL
public static final String JDBC_MAX_CONNECTIONS_PROPERTY
public static final String JDBC_MAX_CONNECTIONS_PER_ROUTE_PROPERTY
public static Map<HttpClientSettingsKey,org.apache.http.impl.client.CloseableHttpClient> httpClient
public static long getDownloadedConditionTimeoutInSeconds()
public static void closeExpiredAndIdleConnections()
public static void setProxyForS3(HttpClientSettingsKey key, com.amazonaws.ClientConfiguration clientConfig)
key - key to HttpClient map containing OCSP and proxy infoclientConfig - the configuration needed by S3 to set the proxypublic static void setSessionlessProxyForS3(Properties proxyProperties, com.amazonaws.ClientConfiguration clientConfig) throws SnowflakeSQLException
proxyProperties - proxy propertiesclientConfig - the configuration needed by S3 to set the proxySnowflakeSQLExceptionpublic static void setSessionlessProxyForAzure(Properties proxyProperties, com.microsoft.azure.storage.OperationContext opContext) throws SnowflakeSQLException
proxyProperties - proxy propertiesopContext - the configuration needed by Azure to set the proxySnowflakeSQLExceptionpublic static void setProxyForAzure(HttpClientSettingsKey key, com.microsoft.azure.storage.OperationContext opContext)
key - key to HttpClient map containing OCSP and proxy infoopContext - the configuration needed by Azure to set the proxypublic static org.apache.http.impl.client.CloseableHttpClient buildHttpClient(@Nullable HttpClientSettingsKey key, File ocspCacheFile, boolean downloadCompressed)
key - Key to HttpClient hashmap containing OCSP mode and proxy information, could be nullocspCacheFile - OCSP response cache file. If null, the default OCSP response file will be
used.downloadCompressed - Whether the HTTP client should be built requesting no decompressionpublic static void updateRoutePlanner(HttpClientSettingsKey key)
public static org.apache.http.impl.client.CloseableHttpClient getHttpClient(HttpClientSettingsKey ocspAndProxyKey)
ocspAndProxyKey - OCSP mode and proxy settings for httpclientpublic static org.apache.http.impl.client.CloseableHttpClient getHttpClientWithoutDecompression(HttpClientSettingsKey ocspAndProxyKey)
ocspAndProxyKey - OCSP mode and proxy settings for httpclientpublic static org.apache.http.impl.client.CloseableHttpClient initHttpClientWithoutDecompression(HttpClientSettingsKey key, File ocspCacheFile)
key - contains information needed to build specific HttpClientocspCacheFile - OCSP response cache file name. if null, the default file will be used.public static org.apache.http.impl.client.CloseableHttpClient initHttpClient(HttpClientSettingsKey key, File ocspCacheFile)
key - contains information needed to build specific HttpClientocspCacheFile - OCSP response cache file name. if null, the default file will be used.public static org.apache.http.client.config.RequestConfig getDefaultRequestConfigWithSocketTimeout(int soTimeoutMs,
boolean withoutCookies)
soTimeoutMs - - custom socket timeout in milli-secondswithoutCookies - - whether this request should ignore cookies or notpublic static org.apache.http.client.config.RequestConfig getDefaultRequestConfigWithSocketAndConnectTimeout(int requestSocketAndConnectTimeout,
boolean withoutCookies)
requestSocketAndConnectTimeout - - custom socket and connect timeout in milli-secondswithoutCookies - - whether this request should ignore cookies or notpublic static org.apache.http.client.config.RequestConfig getRequestConfigWithoutCookies()
public static void setRequestConfig(org.apache.http.client.config.RequestConfig requestConfig)
public static void setSocksProxyDisabled(boolean socksProxyDisabled)
socksProxyDisabled - new valuepublic static boolean isSocksProxyDisabled()
public static String executeGeneralRequest(org.apache.http.client.methods.HttpRequestBase httpRequest, int retryTimeout, int authTimeout, int socketTimeout, int retryCount, HttpClientSettingsKey ocspAndProxyKey) throws SnowflakeSQLException, IOException
httpRequest - HttpRequestBaseretryTimeout - retry timeoutauthTimeout - authenticator specific timeoutsocketTimeout - socket timeout (in ms)retryCount - retry count for the requestocspAndProxyKey - OCSP mode and proxy settings for httpclientSnowflakeSQLException - if Snowflake error occursIOException - raises if a general IO error occurspublic static String executeGeneralRequest(org.apache.http.client.methods.HttpRequestBase httpRequest, int retryTimeout, int authTimeout, int socketTimeout, int retryCount, org.apache.http.impl.client.CloseableHttpClient httpClient) throws SnowflakeSQLException, IOException
httpRequest - HttpRequestBaseretryTimeout - retry timeoutauthTimeout - authenticator specific timeoutsocketTimeout - socket timeout (in ms)retryCount - retry count for the requesthttpClient - client object used to communicate with other machineSnowflakeSQLException - if Snowflake error occursIOException - raises if a general IO error occurspublic static String executeRequest(org.apache.http.client.methods.HttpRequestBase httpRequest, int retryTimeout, int authTimeout, int socketTimeout, int retryCount, int injectSocketTimeout, AtomicBoolean canceling, boolean includeRetryParameters, boolean retryOnHTTP403, HttpClientSettingsKey ocspAndProxyKey) throws SnowflakeSQLException, IOException
httpRequest - HttpRequestBaseretryTimeout - retry timeoutauthTimeout - authenticator timeoutsocketTimeout - socket timeout (in ms)retryCount - retry count for the requestinjectSocketTimeout - injecting socket timeoutcanceling - canceling?includeRetryParameters - whether to include retry parameters in retried requestsretryOnHTTP403 - whether to retry on HTTP 403 or notocspAndProxyKey - OCSP mode and proxy settings for httpclientSnowflakeSQLException - if Snowflake error occursIOException - raises if a general IO error occursCopyright © 2022. All rights reserved.