List of usage examples for io.vertx.core.http HttpClient redirectHandler
@Fluent HttpClient redirectHandler(Function<HttpClientResponse, Future<HttpClientRequest>> handler);
From source file:examples.HTTPExamples.java
License:Open Source License
public void exampleFollowRedirect03(HttpClient client) { client.redirectHandler(response -> { // Only follow 301 code if (response.statusCode() == 301 && response.getHeader("Location") != null) { // Compute the redirect URI String absoluteURI = resolveURI(response.request().absoluteURI(), response.getHeader("Location")); // Create a new ready to use request that the client will use return Future.succeededFuture(client.getAbs(absoluteURI)); }/*from w ww. ja v a 2s.c o m*/ // We don't redirect return null; }); }