1. If I follow redirects
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("http://....";
method.setFollowRedirects(true);
client.executeMethod(method);
System.out.println(method.getURI());
method.releaseConnection();
Yes, then I can compare the first and the second URLs.
2. If I do not follow the redirect
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("http://....";
method.setFollowRedirects(false);
client.executeMethod(method);
Header header = method.getResponseHeader("Location");
// when header!=null
System.out.println(header.getValue());
method.releaseConnection();
Which solution do you think is nicer or less resource intensive? I need
to do about 17,000 validations so I care about speed too.
Thanks.
sebb wrote:
method.getURI()
On 12/05/2008, Janos Mucsi <[EMAIL PROTECTED]> wrote:
Hi
I am following redirects like this
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("http://....";
method.setFollowRedirects(true);
client.executeMethod(method);
I would like to compare the new URL to the old URL in case of redirects.
What is the most efficient way
to do this if I do not want to make two separate connections?
Have you tried calling
method.getURI()
after the executeMethod() has returned?
In my case this is necessary because the company I am working for uses
redirects just to change cookies,
so I need to distinguish between real redirects (when the URL is different)
and fake redirects (when cookies
are different only).
Thanks.
--
Janos Mucsi
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Janos Mucsi
415-222-1411