I try to get HTTP data before redirection when Android tries to connect to Captive Portal.
Here is snippets of code:
httpclient = new DefaultHttpClient(/*params*/);
String url = "http://google.com";
Log.d("test_runner", "URL: " + url);
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
entity.consumeContent();
}
for(Header h : response.getAllHeaders()){
Log.d("test_runner", h.toString());
}
Log.d("test_runner", response.getStatusLine().getStatusCode() + "");
response.getStatusLine();
When I use Fiddler Web Debugger
I see followed flow:
So 1st off I need receive status 302 and after redirect status 200.
However, I straight get response after redirection.
Sounds like Android does redirect automatically and I can't catch it.
How can I fetch response information before redirection (a.e. 1st row from Fiddler, header of 302)?
Thank you
I found solution, (didn't think so quickly)
HttpParams params = new BasicHttpParams();
HttpClientParams.setRedirecting(params, false);
httpclient = new DefaultHttpClient(params);
....