Search in sources :

Example 1 with AsyncHttpClientMiddleware

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;
}
Also used : AsyncHttpClientMiddleware(com.koushikdutta.async.http.AsyncHttpClientMiddleware) IOException(java.io.IOException) FileCache(com.koushikdutta.async.util.FileCache)

Aggregations

AsyncHttpClientMiddleware (com.koushikdutta.async.http.AsyncHttpClientMiddleware)1 FileCache (com.koushikdutta.async.util.FileCache)1 IOException (java.io.IOException)1