Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Any way to overcome Circular Redirect using HttpClient 4.1.1
Raihan Jamal
Ranch Hand
Posts: 86
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How can I avoid circular redirect using HttpClient 4.1.1. As I am getting the error like this:-
executing requestGET http://qhome.somehost.com/MyQualnet/pages/corporateHome.xhtml HTTP/1.1 org.apache.http.client.ClientProtocolException at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:822) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754) at edu.uci.ics.crawler4j.url.WebURL.setURL(WebURL.java:122) at edu.uci.ics.crawler4j.crawler.CrawlController.addSeed(CrawlController.java:207) at edu.uci.ics.crawler4j.example.advanced.Controller.main(Controller.java:31) Caused by: org.apache.http.client.CircularRedirectException: Circular redirect to 'http://qhome.somehost.com/MyQualnet/pages/corporateHome.xhtml' at org.apache.http.impl.client.DefaultRedirectStrategy.getLocationURI(DefaultRedirectStrategy.java:168) at org.apache.http.impl.client.DefaultRedirectStrategy.getRedirect(DefaultRedirectStrategy.java:193) at org.apache.http.impl.client.DefaultRequestDirector.handleResponse(DefaultRequestDirector.java:1021) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:482) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
This is my code...
DefaultHttpClient client = null; try { // Set url //URI uri = new URI(url.toString()); client = new DefaultHttpClient(); client.getCredentialsProvider().setCredentials( new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM), new UsernamePasswordCredentials("test", "test")); URL url1 = new URL (url); HttpURLConnection connection = (HttpURLConnection) url1.openConnection(); connection.setFollowRedirects(false); HttpGet request = new HttpGet(url); final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); HttpContext context = new BasicHttpContext(); System.out.println("----------------------------------------"); System.out.println("executing request" + request.getRequestLine()); HttpResponse response = client.execute(request, context); HttpEntity entity = response.getEntity(); System.out.println(response.getStatusLine()); InputStream content = entity.getContent(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { // System.out.println(line); } } catch(Exception e) { e.printStackTrace(); }
Paul Clapham
Marshal
Posts: 28193
95
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What do you mean by "avoid circular redirect"?
Rob Spoor
Sheriff
Posts: 22783
131
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Two or more pages are probably automaticly redirecting to each other. Or worse, one page is automaticly redirecting to itself.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Trying to Redirect. 302 Error. HTTP CLIENT
HTTP/1.1 401 Authorization Required with HttpClient 4.1.1
http client + thread save conn manager + execute get request time problems
HttpClient Exception
java.net.ConnectException: Connection timed out in HttpClient
More...