> org.apache.commons.httpclient.HttpException: Redirect from host www.google.com to > www.google.com.tr is not supported
Emre, www.google.com != www.google.com.tr HttpClient 2.0 does not support cross host redirects. Period. We are sorry. The redirect guide you have already been referred to explains why and what can be done to work the problem around http://jakarta.apache.org/commons/httpclient/redirects.html Development (unstable) version of HttpClient can automatically handle cross-host redirects already. Oleg -----Original Message----- From: Emre Sokullu [mailto:[EMAIL PROTECTED] Sent: Friday, February 27, 2004 18:26 To: Commons HttpClient Project Subject: 302 !! Hi all, I still couldn't solve my problem with http status 302 : When I try to connect Google, it redirects me to the local page : http://www.google.com.tr At this status, I want to catch the new address and try to reconnect but such a failure occurs : 27.Ìub.2004 17:48:13 org.apache.commons.httpclient.HttpMethodBase checkValidRedirect WARNING: Error getting URI host org.apache.commons.httpclient.HttpException: Redirect from host www.google.com to www.google.com.tr is not supported at org.apache.commons.httpclient.HttpMethodBase.checkValidRedirect(HttpM ethodBase.java:1243) at org.apache.commons.httpclient.HttpMethodBase.processRedirectResponse( HttpMethodBase.java:1191) at org.apache.commons.httpclient.HttpMethodBase.isRetryNeeded(HttpMethod Base.java:977) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.j ava:1095) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.jav a:675) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.jav a:529) at WebClient.fetchHTML(WebClient.java:343) at Jetch.<init>(Jetch.java:99) at d2.main(d2.java:26) 27.Ìub.2004 17:48:13 org.apache.commons.httpclient.HttpMethodBase processRedirectResponse WARNING: Invalid Redirect URI from: http://www.google.com:80/ to: http://www.google.com.tr/cxfer?c=PREF%3D:TM%3D1077896890:S%3D-1ZixmjyLNwVsU16 And my code is the following : HttpMethod method; if (this.methodPost) { method = new PostMethod(this.url); } else { method = new GetMethod(this.url); } method.setStrictMode(false); // also tried true; the same result method.setFollowRedirects(true); Header locationHeader = method.getResponseHeader("location"); if(locationHeader != null ) { String redirectLocation = locationHeader.getValue(); this.tryAgain(redirectLocation); return; } else {} int attempt = 0; while (this.statusCode == -1 && attempt < 10) { try { this.statusCode = this.client.executeMethod(method); } catch (HttpRecoverableException e) { System.err.println( "A recoverable exception occurred, retrying." + e.getMessage()); } catch (IOException e) { System.err.println("Failed to download file."); e.printStackTrace(); System.exit( -1); } } this.responseBody = method.getResponseBodyAsString(); method.releaseConnection(); Thanx very much for your interest... *************************************************************************************************** The information in this email is confidential and may be legally privileged. Access to this email by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system. *************************************************************************************************** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]