users@jersey.java.net

[Jersey] Redirect to https endpoint not followed by client

From: Richard Martell <rmartell_at_galdosinc.com>
Date: Wed, 8 May 2013 16:01:35 -0700

All,


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());
}


Log output:

1 * Client out-bound request
1 > GET http://developers.google.com/kml/documentation/images/etna.jpg
1 * Client in-bound response
1 < 302
1 < Date: Wed, 08 May 2013 22:36:46 GMT
1 < Content-Length: 0
1 < Location: https://developers.google.com/kml/documentation/images/etna.jpg
1 < Content-Type: text/html
1 < Server: Google Frontend
1 <


Note: This works fine with "http://example.com", which also yields a 302 response
(to http://example.iana.org/).


Regards,

--
Richard