title: JAX-RS : Client side: Intercepting redirection before the redirections are followed
body: <p>I am trying to implement &quot;redirect handler/filter&quot; on JAX-RS(Jersey) client side. The expectation is that this handler would get invoked before actual redirection by Jersey takes place.</p>
  <p>So far I could find is to disable follow redirect and implement own redirect  filter, but this means I have to implement full redirect handling including handling loops or other edge cases, which I am trying to avoid and want to rely on Jersey implementation.</p>
  <p>I only want to add/change header or other parameters inside the request before actual redirection takes place. Also there are only few redirect we want to manipulate while let other redirections work as is.</p>
  <p>Disabling redirect:</p>
  <pre><code>ClientBuilder
                  .newBuilder()
                  .withConfig(new ClientConfig(clientConfig))
                  .property(ClientProperties.FOLLOW_REDIRECTS, false)
                  .build();
  </code></pre>
  <p>Sample redirect handler:</p>
  <pre><code>        Response resp = requestContext.getClient().target(responseContext.getLocation()).request()
                  .method(requestContext.getMethod());
          responseContext.setEntityStream((InputStream) resp.getEntity());
          responseContext.setStatusInfo(resp.getStatusInfo());
          responseContext.setStatus(resp.getStatus());
  </code></pre>
  <p>Are there any pointers or reference I can use to intercept redirect?</p>