users@jersey.java.net

[Jersey] Redirect to https endpoint not followed by client

From: Marko Asplund <marko.asplund_at_gmail.com>
Date: Sun, 2 Jun 2013 11:10:20 +0300

Richard wrote:
> Using the current release of the Jersey client, it seems that if a redirect
> (302) switches to the 'https' scheme it's not followed even if the client
> is configured to do so. Is this a bug or did I overlook something?
>
>
> Client client = new Client();
> client.setFollowRedirects(true);
> client.addFilter(new LoggingFilter(System.out));
> URI uri = URI.create("http://developers.google.com/kml/documentation/images/etna.jpg");
> WebResource resource = client.resource(uri);
> ClientResponse rsp = resource.get(ClientResponse.class);
> if (rsp.hasEntity()) {
> System.out.println(rsp.getLength());
> }

I also bumped into this same problem this week.
In addition to the Jersey standard client API I also tried using the
Jersey ApacheHttpClient, but that didn't work either.

I was able to achieve the intended redirect behaviour using Apache
HttpClient v4 with LaxRedirectStrategy.

marko