On 11/11/2008, Amy de Buitléir <[EMAIL PROTECTED]> 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 httpMethod.getURI() 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
