hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Finding out the URL after a redirect
Date Tue, 11 Nov 2008 11:53:36 GMT
On 11/11/2008, Amy de Buitléir <amy@nualeargais.ie> wrote:
> Is there a way to find out what URL a request was redirected to? Here's the
>  scenario:
>  1. My code (client) does a GET http:/a/b/x
>  2. Server redirects to http://a/b/c/x (HttpClient handles the redirect)
>  3. Parsing the page, my code finds a link with a relative URL, "../y".
>  4. My code thinks the base URL is http:/a/b/x, so it resolves the partial
>  URL in the link to http:/a/y and tries to fetch that page.
>     HOWEVER, the base URL is really http://a/b/c/x, so the link is really to
>  http://a/b/y.
>  If there were some way to check for redirects, then my code could cope with
>  them. When I was using HttpClient 3, I used to handle the redirects in my
>  code, so I could continue to do that if necessary. However, HttpClient 4
>  seems to handle redirects better than HttpClient 3 did, and I'd like to take
>  advantage of that.
>  I believe I'm asking the same question as was asked here:
>  http://mail-archives.apache.org/mod_mbox/hc-httpclient-users/200810.mbox/browser.
>  I have read the replies to that post, however, I don't think those replies
>  really addressed the scenario. If there isn't currently a way to find out
>  the redirected URL, then perhaps I should enter a feature request. Thanks in
>  advance for any suggestions.

In HttpClient 3.1, one can use


after the event to get the updated URI.

Not sure about HC 4.x, but it may well behave the same - try it and see.

To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message