1

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.

saikamesh
  • 4,569
  • 11
  • 53
  • 93
  • Did you seen "30x redirection handling" section in [docs](http://vertx.io/docs/vertx-core/java/)? – zella Sep 26 '17 at 12:31
  • I read. It is saying setFollowRedirects(true) can be used. But I am using io.vertx.rxjava.core.http.HttpClient class. There no such a method is available. – saikamesh Sep 27 '17 at 09:15
  • Not `HttpClient`, but `io.vertx.rxjava.core.http.HttpClientRequest` – zella Sep 27 '17 at 11:22
  • I am using vertx version 3.3.0. The mentioned method is not available in io.vertx.rxjava.core.http.HttpClientRequest. – saikamesh Sep 28 '17 at 14:00

1 Answers1

5

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();
tsegismont
  • 8,591
  • 1
  • 17
  • 27
  • 1
    io.vertx.rxjava.core.http.HttpClient does not have such a property. How do we handle redirection in this API – saikamesh Sep 27 '17 at 09:13
  • The [method](http://vertx.io/docs/apidocs/io/vertx/rxjava/core/http/HttpClientRequest.html#setFollowRedirects-boolean-) is on `HttpServerRequest`, not `HttpClient`. – tsegismont Sep 27 '17 at 14:00