Skip to content

Commit c8dbffc

Browse files
frosforeversfc-gh-snoonan
authored andcommitted
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 3187a8e commit c8dbffc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

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

0 commit comments

Comments
 (0)