Hi,

We are using HttpClient version 4.2.5 and we did try the
option client.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS,
true);, however this hits maximum redirects hits occurred around 100.

On Tue, Oct 14, 2014 at 7:44 PM, Todd W Lainhart <[email protected]>
wrote:

> You can turn off circular redirect checking.  You haven't said what
> version of the library you're using.  Assuming the latest, take a look at
> RequestConfig.Builder.  There are other options/mechanisms for raising the
> limits, or taking part in the analysis process.
>
>
>
>
>
> Todd Lainhart
> Rational software
> IBM Corporation
> 550 King Street, Littleton, MA 01460-1250
> 1-978-899-4705
> 2-276-4705 (T/L)
> [email protected]
>
>
>
>
> From:   srihari na <[email protected]>
> To:     HttpClient User Discussion <[email protected]>
> Date:   10/14/2014 10:04 AM
> Subject:        HttpClient with CircularRedirectException
>
>
>
> Hello,
>
> We are trying a simple Get request to a server which is seems to be in
> circular redirection and end up in CircularRedirectException, based on
> some
> internet search hits there is a mechanism to disable the
> circuralRedirectionException, however we hit maximum redirection hits(100)
> occurred. We were able to hit the same server with a simple standalone
> java
> program, Mozilla and Chrome ReST client which is working fine where as the
> Apache client libraries is throwing the above mentioned exception. I have
> pasted the code snippet below and java program, please help me overcome
> this situation. The Authorization header is intentionally garbled for
> security reasons however with the code error is reproduced and with proper
> header also we see the problem.
>
> DefaultHttpClient httpclient = new DefaultHttpClient();
>         try {
>             KeyStore trustStore  =
> KeyStore.getInstance(KeyStore.getDefaultType());
>             FileInputStream instream = new FileInputStream(new
> File("C:\\IBMJDK7\\jre\\lib\\security\\cacerts"));
>             try {
>                 trustStore.load(instream, "changeit".toCharArray());
>             } finally {
>                 try { instream.close(); } catch (Exception ignore) {}
>             }
>
>             SSLSocketFactory socketFactory = new
> SSLSocketFactory(trustStore);
>             Scheme sch = new Scheme("https", 443, socketFactory);
>
> httpclient.getConnectionManager().getSchemeRegistry().register(sch);
>
>             HttpGet httpget = new HttpGet("
> https://login.eloqua.com:443/id/
> ");
>             httpget.addHeader("Authorization", "Basic
> VGVjaG5vbG9neVBhcnRuZXJQZXJzaX");
>             httpget.addHeader("Accept","application/json");
>             System.out.println("executing request" +
> httpget.getRequestLine());
>
>             HttpResponse response = httpclient.execute(httpget);
>             HttpEntity entity = response.getEntity();
>             System.out.println(response.getStatusLine());
>             if (entity != null) {
>                 System.out.println("Response content length: " +
> entity.getContentLength());
>             }
>             EntityUtils.consume(entity);
>
>         } finally {
>             httpclient.getConnectionManager().shutdown();
>         }
>
> Sample Java Code
>
> public class TestEloquaJavaHttpUrl {
>
>     public static void main(String [] args) throws Exception {
>         // configure the SSLContext with a TrustManager
>         SSLContext ctx = SSLContext.getInstance("SSLv3");
>         ctx.init(new KeyManager[0], new TrustManager[] {new
> DefaultTrustManager()}, new SecureRandom());
>         SSLContext.setDefault(ctx);
>
>         URL url = new URL("https://login.eloqua.com:443/id/";);
>         HttpsURLConnection conn = (HttpsURLConnection)
> url.openConnection();
>         conn.setRequestProperty("Authorization", "Basic
> VGVjaG5vbG9neVBhcnRuZXJQZXJzaX");
>         conn.setRequestProperty("Accept", "application/json");
>         conn.setHostnameVerifier(new HostnameVerifier() {
>             @Override
>             public boolean verify(String arg0, SSLSession arg1) {
>                 return true;
>             }
>         });
>         System.out.println(conn.getResponseCode());
>         conn.disconnect();
>     }
>
>     private static class DefaultTrustManager implements X509TrustManager {
>
>         @Override
>         public void checkClientTrusted(X509Certificate[] arg0, String
> arg1)
> throws CertificateException {}
>
>         @Override
>         public void checkServerTrusted(X509Certificate[] arg0, String
> arg1)
> throws CertificateException {}
>
>         @Override
>         public X509Certificate[] getAcceptedIssuers() {
>             return null;
>         }
>     }
> }
>
> --
> Regards,
> Srihari NA
>
>


-- 
Regards,
Srihari NA

Reply via email to