Skip to content

Commit 3141c2b

Browse files
committed
- fixes a bug where chunk encoding would make the redirect handler fail
1 parent 947d384 commit 3141c2b

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎src/main/java/com/microsoft/graph/httpcore/HttpClients.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import okhttp3.Interceptor;
1111
import okhttp3.OkHttpClient;
1212
import okhttp3.Protocol;
13-
import okhttp3.Request;
1413
import okhttp3.OkHttpClient.Builder;
1514

1615
/**
@@ -32,6 +31,7 @@ public static Builder custom() {
3231
return new OkHttpClient.Builder()
3332
.addInterceptor(new TelemetryHandler())
3433
.followRedirects(false)
34+
.followSslRedirects(false)
3535
.protocols(Arrays.asList(Protocol.HTTP_1_1)); //https://stackoverflow.com/questions/62031298/sockettimeout-on-java-11-but-not-on-java-8
3636
}
3737

‎src/main/java/com/microsoft/graph/httpcore/RedirectHandler.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,16 @@ public Response intercept(@Nonnull final Chain chain) throws IOException {
132132

133133
while(true) {
134134
response = chain.proceed(request);
135-
boolean shouldRedirect = isRedirected(request, response, requestsCount, redirectOptions)
135+
final boolean shouldRedirect = isRedirected(request, response, requestsCount, redirectOptions)
136136
&& redirectOptions.shouldRedirect().shouldRedirect(response);
137137
if(!shouldRedirect) break;
138138

139-
Request followup = getRedirect(request, response);
140-
if(followup == null) break;
141-
request = followup;
142-
143-
requestsCount++;
139+
final Request followup = getRedirect(request, response);
140+
if(followup != null) {
141+
response.close();
142+
request = followup;
143+
requestsCount++;
144+
}
144145
}
145146
return response;
146147
}

0 commit comments

Comments
 (0)