Using the AndroidHttpClient with cookies gives me intermixed 200 ok and 403 forbidden responses. I'm not sure what I am doing wrong.
I'm using the AndroidHttpClient in the following manner:
I have several background thread classes, and each one does the following:
HttpGet get...
HttpClient client = AndroidHttpClient.newInstance("Android");
HttpContext http_context = HttpSupport.getHttpContextInstance();
CookieStore cookie_store = HttpSupport.getCookieStoreInstance();
http_context.setAttribute(ClientContext.COOKIE_STORE, cookie_store);
client.execute(
HttpSupport is a class with two static fields; a CookieStore and a HttpContext:
public class HttpSupport {
private static HttpContext _context;
private static CookieStore _cookieStore;
public static synchronized HttpContext getHttpContextInstance() {
if (_context == null) {
_context = new BasicHttpContext();
}
return _context;
}
public static synchronized CookieStore getCookieStoreInstance() {
if (_cookieStore == null) {
_cookieStore = new BasicCookieStore();
}
return _cookieStore;
}
}
Is it ok to have multiple instances of the AndroidHttpClient in the application? Am I storing the cookies correctly?