Apache HttpClient: Location of redirected URLs
I'm using Apache's HttpClient (for Java) load a Url that is getting redirected by a HTTP 301 response. The good news, HttpClient follows this redirect automatically, and I don't need to manually loop through the redirects.
The part I haven't figured out is my final destination. Because I'm getting the headers of the final开发者_StackOverflow successful (HTTP 200) query, there is no Location header. Since the redirect occurs behind the scenes of the HttpClient.execute(..), my code doesn't know whether there has been a redirect, and where it has redirected to.
How do I get this vital piece of information? Do I really need to recode this in java.net classes to get this info?
For the record, I'm using the Apache HttpClient on Android, and need backward compatibility back to Android 1.6.
All hail the RedirectHandler (helps to read the docs)
精彩评论