Skip to content

Commit 52b601e

Browse files
authored
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.
1 parent 78e3163 commit 52b601e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/net/snowflake/client/core/HttpUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
5555
import org.apache.http.impl.client.BasicCredentialsProvider;
5656
import org.apache.http.impl.client.CloseableHttpClient;
57-
import org.apache.http.impl.client.DefaultRedirectStrategy;
57+
import org.apache.http.impl.client.LaxRedirectStrategy;
5858
import org.apache.http.impl.client.HttpClientBuilder;
5959
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
6060
import org.apache.http.protocol.HttpContext;
@@ -392,7 +392,7 @@ public static CloseableHttpClient buildHttpClient(
392392
.setConnectionManager(connectionManager)
393393
// Support JVM proxy settings
394394
.useSystemProperties()
395-
.setRedirectStrategy(new DefaultRedirectStrategy())
395+
.setRedirectStrategy(new LaxRedirectStrategy())
396396
.setUserAgent(buildUserAgent(userAgentSuffix)) // needed for Okta
397397
.disableCookieManagement() // SNOW-39748
398398
.setDefaultRequestConfig(DefaultRequestConfig);

0 commit comments

Comments
 (0)