use of com.github.ignition.support.http.cache.HttpResponseCache in project ignition by mttkay.
the class IgnitedHttpSampleActivity method updateCacheStatus.
public void updateCacheStatus() {
EditText memoryCacheText = (EditText) findViewById(R.id.ignitedhttp_text_cache_memory);
memoryCacheText.setText("");
EditText diskCacheText = (EditText) findViewById(R.id.ignitedhttp_text_cache_disk);
diskCacheText.setText("");
HttpResponseCache cache = http.getResponseCache();
if (cache != null) {
for (String key : cache.keySet()) {
if (cache.containsKeyInMemory(key)) {
memoryCacheText.append(cache.getFileNameForKey(key) + "\n");
}
}
List<File> cachedFiles = cache.getCachedFiles();
for (File file : cachedFiles) {
diskCacheText.append(file.getName() + "\n");
}
}
}
use of com.github.ignition.support.http.cache.HttpResponseCache in project ignition by mttkay.
the class IgnitedHttpRequestBase method handleResponse.
@Override
public IgnitedHttpResponse handleResponse(HttpResponse response) throws IOException {
int status = response.getStatusLine().getStatusCode();
if (expectedStatusCodes != null && !expectedStatusCodes.isEmpty() && !expectedStatusCodes.contains(status)) {
throw new HttpResponseException(status, "Unexpected status code: " + status);
}
IgnitedHttpResponse bhttpr = new IgnitedHttpResponseImpl(response);
HttpResponseCache responseCache = ignitedHttp.getResponseCache();
if (responseCache != null && bhttpr.getResponseBody() != null) {
ResponseData responseData = new ResponseData(status, bhttpr.getResponseBodyAsBytes());
responseCache.put(getRequestUrl(), responseData);
}
return bhttpr;
}
Aggregations