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...