commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "otisg" <ot...@iVillage.com>
Subject [httpclient]: Q about HttpMultiClient and redirects
Date Mon, 06 May 2002 22:54:21 GMT
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. 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message