From c8dbffcac9f9621cda94d87473416a81a044db88 Mon Sep 17 00:00:00 2001 From: Yosef Fertel <1630422+frosforever@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:50:14 -0400 Subject: [PATCH] Update HttpClient to use LaxRedirectStrategy to handle `307` on `POST` Currently used `DefaultRedirectStrategy` will not redirect on `POST` requests when a `307` is received. `LaxRedirectStrategy`, on the other hand, will accept redirects regardless of the method. Snowflake service sometimes returns `307` on `POST`. Discussions with support indicated that while this shouldn't happen it can be returned to the client and should be retried in user code. If the retry strategy in the http client is updated to `LaxRedirectStrategy` there would be no need for users to handle this explicitly. --- src/main/java/net/snowflake/client/core/HttpUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/snowflake/client/core/HttpUtil.java b/src/main/java/net/snowflake/client/core/HttpUtil.java index 5f678b074c..a0e202397a 100644 --- a/src/main/java/net/snowflake/client/core/HttpUtil.java +++ b/src/main/java/net/snowflake/client/core/HttpUtil.java @@ -53,7 +53,7 @@ import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.DefaultRedirectStrategy; +import org.apache.http.impl.client.LaxRedirectStrategy; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.protocol.HttpContext; @@ -391,7 +391,7 @@ public static CloseableHttpClient buildHttpClient( .setConnectionManager(connectionManager) // Support JVM proxy settings .useSystemProperties() - .setRedirectStrategy(new DefaultRedirectStrategy()) + .setRedirectStrategy(new LaxRedirectStrategy()) .setUserAgent(buildUserAgent(userAgentSuffix)) // needed for Okta .disableCookieManagement() // SNOW-39748 .setDefaultRequestConfig(DefaultRequestConfig);