class ClientMain {

    static CompletionStage<String> followRedirects(WebClient webClient) {
        System.out.println("Following request redirection.");
        return webClient.get()
                .path("/redirect")
                .request()
                .thenCompose(response -> {
                    if (response.status() != Http.Status.OK_200) {
                        throw new IllegalStateException("Follow redirection failed!");
                    }
                    return response.content().as(String.class);
                })
                .thenCompose(string -> {
                    System.out.println("Redirected request successfully followed.");
                    System.out.println(string);
                    return CompletableFuture.completedFuture(string);
                });
    }

    private  ClientMain();

}