use of com.koushikdutta.async.http.AsyncHttpClientMiddleware in project AndroidAsync by koush.
the class ResponseCacheMiddleware method addCache.
public static ResponseCacheMiddleware addCache(AsyncHttpClient client, File cacheDir, long size) throws IOException {
for (AsyncHttpClientMiddleware middleware : client.getMiddleware()) {
if (middleware instanceof ResponseCacheMiddleware)
throw new IOException("Response cache already added to http client");
}
ResponseCacheMiddleware ret = new ResponseCacheMiddleware();
ret.server = client.getServer();
ret.cache = new FileCache(cacheDir, size, false);
client.insertMiddleware(ret);
return ret;
}
Aggregations