android - Handling HTTP request redirect in java -


i'm writing network android application uses http requests data. data html format. use apache httpclient , jsoup.

when i'm out of traffic mobile internet provider, redirected providers' page saying should pay money. of course, bad idea parse page.

how detect occured page substitution?

this code know final target of request, if isn't page asked for, provider page.

defaulthttpclient httpclient = new defaulthttpclient(); httpcontext localcontext = new basichttpcontext(); httpget httpget = new httpget("http://www.google.com/"); httpresponse response = httpclient.execute(httpget, localcontext); httphost target = (httphost) localcontext.getattribute(  executioncontext.http_target_host);// final page of request system.out.println("final target: " + target); httpentity entity = response.getentity(); entityutils.consume(entity); 

thanks


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -