in src/main/java/com/spotify/github/v3/clients/GitHubClient.java [1179:1202]
CompletableFuture<HttpResponse> processPossibleRedirects(
final HttpResponse response, final AtomicBoolean redirected) {
if (response.statusCode() >= PERMANENT_REDIRECT
&& response.statusCode() <= TEMPORARY_REDIRECT
&& !redirected.get()) {
redirected.set(true);
// redo the same request with a new URL
final String newLocation = response.headers().get("Location").get(0);
return requestBuilder(newLocation)
.thenCompose(
requestBuilder -> {
HttpRequest request =
requestBuilder
.url(newLocation)
.method(response.request().method())
.body(response.request().body())
.build();
// Do the new call and complete the original future when the new call completes
return call(request);
});
}
return completedFuture(response);
}