On 07/01/2010 11:38 AM, MobDev wrote:
Hi, I'd like to know how to do a HTTP GET request to a server from
which I know I will get redirected at least a couple of times... I'd
like to get the response (body) of the "last" webpage. It should come
up with a code in my specific example...

Or, as an alternative, I do know you can start the browser from within
your Android app, is it possible to actually retrieve the body from
that ?

Any help, tips, source whatever would be helpfull, cause till now I
have found (and tried) like 4 methods and to me it seems there is a
jungle of HttpGet, HttpClient, HttpResponse etc libraries ?

I haven't tried this, but I believe what you'll need to do is check the HTTP status, and look for a new URL/URI in the response headers. Web servers usually issue redirect responses with a 300 level response code, most commonly 301 (permanent redirect) or 302 (temporary redirect). In either case, they're supposed to provide a new absolute URL, though many only provide a relative URI (the path and file name on the server) in a "Location" header. So you'll probably need to issue a new get request to the new URL. When you're either tired of bouncing around (HTTP clients are only suggested to handle up to 5 redirects), or when you hit a non 300 level response code, then you're at your final destination, but there's nothing saying you can't keep the responses from every bounce along the way...

Raymond

--
Raymond Rodgers
http://www.badlucksoft.com/

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to