You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by otisg <ot...@iVillage.com> on 2002/05/07 00:54:21 UTC

[httpclient]: Q about HttpMultiClient and redirects

Hello,

Is there a way to 'catch' redirected URLs when using HttpMultiClient?
It seems like this block of code, which is a part of executeMethod
method, always gets executed if the status code matches.
Wouldn't it be useful to have a setFollowRedirects(boolean) method in
HttpMultiClient, as well as a matching getFollowRedirects() method? If I
were to use HttpMultiClient, and I'd like to, I would need this, since I
need to differentiate between URLs that return a 200 OK, and one of the
resource moved codes.

if (status == 301 || status == 302 || 
status == 303 || status == 307)
{
Header header = method.getResponseHeader("Location");
String url = header.getValue();
if (url == null)
{
log.error("HttpMultiClient.executeMethod: Received redirect without
Location header.");
throw new HttpException("Received redirect without Location header.");
}

method.recycle();
method.setUrl(url);
return executeMethod(method);
}

I can provide patch....just let me know, since I can't commit to
commons.

Thanks,
Otis
_______________________________________________________________
Sign up for FREE iVillage newsletters <http://s.ivillage.com/rd/16705> .
>From health and pregnancy to shopping and relationships, iVillage
has the scoop on what matters most to you.