[Per Andrea B.]
Ma vaffan cloud!
:)
giovedì, novembre 25, 2010
sabato, novembre 20, 2010
HttpClient - disable follow http redirect
I was playing with Apache DefaultHttpClient on Android. HttpClient follows http redirect by default. But I need to disable it. I expected a simple set property on HttpClient or HttpGet. I was wrong. :(
Found two solution after a long googling.
My code:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://....");
Solution 1: set parameter
DefaultHttpClient httpClient = new DefaultHttpClient();
BasicHttpParams params = new BasicHttpParams();
HttpClientParams.setRedirecting(params, false);
httpClient.setParams(params);
HttpGet httpget = new HttpGet("http://....");
Solution 2 - define my own redirecthandler
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.setRedirectHandler(new DefaultRedirectHandler() {
@Override
public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
return false;
}
});
HttpGet httpget = new HttpGet("http://....");
Found two solution after a long googling.
My code:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://....");
Solution 1: set parameter
DefaultHttpClient httpClient = new DefaultHttpClient();
BasicHttpParams params = new BasicHttpParams();
HttpClientParams.setRedirecting(params, false);
httpClient.setParams(params);
HttpGet httpget = new HttpGet("http://....");
Solution 2 - define my own redirecthandler
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.setRedirectHandler(new DefaultRedirectHandler() {
@Override
public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
return false;
}
});
HttpGet httpget = new HttpGet("http://....");
mercoledì, novembre 10, 2010
My first Android test app
My first test on Android. A Memory game for my kids. :)
But it has some bugs. First of all I need to fix the layout when rotated. :(
But it has some bugs. First of all I need to fix the layout when rotated. :(
Iscriviti a:
Post (Atom)