Emre,

Take a look at the executeMethodRedirecting method in the following class:
 
http://core.limewire.org/source/browse/core/com/limegroup/gnutella/http/HttpClientManager.java?rev=1.7&content-type=text/x-cvsweb-markup

Thanks,
 Sam

-----Original Message-----
From: Emre Sokullu [mailto:[EMAIL PROTECTED]
Sent: Saturday, February 28, 2004 5:43 AM
To: Commons HttpClient Project
Subject: Re: 302 !!



Thanx Oleg for your reply,

Yes I've already tried what is written on "Redirects Tutorial page". But the
fact is that, the following procedure does not work for me :

Header locationHeader = method.getResponseHeader("location");

Even for the redirected sites like http://www.google.com, it does return a
null value. Not just google fo every reidrected page.

I've tried to solve the problem by simply commenting the following if
condition from the checkValidUri() method in HttpMethodBase class:

/*

try {

String oldHost = currentUri.getHost();

String newHost = redirectUri.getHost();

if (!oldHost.equalsIgnoreCase(newHost)) {

throw new HttpException("Redirect from host " + oldHost

+ " to " + newHost + " is not supported");

}

} catch (URIException e) {

LOG.warn("Error getting URI host", e);

throw new HttpException("Invalid Redirect URI from: "

+ currentUri.getEscapedURI() + " to: " + redirectUri.getEscapedURI()

);

}

*/



But the main problem is that the URL to conect can't be extracted from the
location header.

I hope I don't waste your time, but it sounds like a bug to me....

Thanx for your help..









----- Original Message -----
From: "Kalnichevski, Oleg" <[EMAIL PROTECTED]>
To: "Commons HttpClient Project" <[EMAIL PROTECTED]>
Sent: Friday, February 27, 2004 7:45 PM
Subject: RE: 302 !!



> 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-1ZixmjyLNwVsU1
6


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]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to