Search code examples
javarx-javavert.xvertx-httpclient

Vertx HttpCllentRequest redirection


How do we handle redirects(302 response code) in vertx HttpClientRequest. Is it possible to enable vertx itself to handle the redirects or we have to handle is explicitly. Please explain how to do it in case it needs to be done explicitly.


Solution

  • The Vert.x HttpClient can be configured to follow redirects as explained in the documentation

    client.get("some-uri", response -> {
      System.out.println("Received response with status code " + response.statusCode());
    }).setFollowRedirects(true).end();