Jersey client not followed by redirects?
I'm struggling to get a Jersey client that follows a redirect, although "I know I've had this before." (Didn't look at the code for a while).
I thought it was a tricky case where it failed when the redirect was from HTTP to HTTPS. But I can't get even this simple test below:
package com.soliantconsulting.jira.test;
import static org.junit.Assert.*;
import com.sun.jersey.api.client.*;
import org.junit.Test;
public class JerseyClientTest {
public void test() {
Client c = Client.create();
c.setFollowRedirects( true );
WebResource r = c.resource("http://www.yahoo.com");
String response = r.get(String.class);
System.out.println( response );
}
}
When run, this code generates:
com.sun.jersey.api.client.UniformInterfaceException: GET http://www.yahoo.com returned a response status of 301 Moved Permanently
I've tried several different options for configuring the redirect-follow option, so I must be doing something fundamentally wrong I guess.
Mac OS 10.9.4, JDK 1.7.0_65, Jersey 1.18.1, Eclipse Luna, Maven 3.2.3.
+3
source to share
No one has answered this question yet
See similar questions:
or similar: