Example usage for com.squareup.okhttp CacheControl noStore

List of usage examples for com.squareup.okhttp CacheControl noStore

Introduction

In this page you can find the example usage for com.squareup.okhttp CacheControl noStore.

Prototype

boolean noStore

To view the source code for com.squareup.okhttp CacheControl noStore.

Click Source Link

Usage

From source file:com.kubeiwu.easyandroid.easyhttp.core.retrofit.GsonConverter.java

License:Apache License

private void parseCache(Request request, T object, String string, String mimeType)
        throws UnsupportedEncodingException {
    com.squareup.okhttp.CacheControl cacheControl = request.cacheControl();
    if (cacheControl != null) {
        if (!cacheControl.noCache() && !cacheControl.noStore()) {
            if (object instanceof EAResult) {
                EAResult kResult = (EAResult) object;
                if (kResult != null && kResult.isSuccess()) {
                    long now = System.currentTimeMillis();
                    long maxAge = cacheControl.maxAgeSeconds();
                    long softExpire = now + maxAge * 1000;
                    System.out.println(":" + (softExpire - now) / 1000 + "");
                    Cache.Entry entry = new Cache.Entry();
                    entry.softTtl = softExpire;
                    entry.ttl = entry.softTtl;
                    // entry.serverDate = serverDate;
                    // entry.responseHeaders = headers;
                    entry.mimeType = mimeType;
                    System.out.println("request.cacheControl()==" + request.cacheControl());
                    entry.data = string.getBytes(UTF8);
                    cache.put(request.urlString(), entry);
                }//from   w ww.  ja va2  s.co m
            }
        }
    }
}

From source file:it.http.HttpHeadersTest.java

License:Open Source License

private static void assertCacheInBrowser(Response httpResponse) {
    CacheControl cacheControl = httpResponse.cacheControl();
    assertThat(cacheControl.mustRevalidate()).isFalse();
    assertThat(cacheControl.noCache()).isFalse();
    assertThat(cacheControl.noStore()).isFalse();
}

From source file:it.http.HttpHeadersTest.java

License:Open Source License

private static void assertNoCacheInBrowser(Response httpResponse) {
    CacheControl cacheControl = httpResponse.cacheControl();
    assertThat(cacheControl.mustRevalidate()).isTrue();
    assertThat(cacheControl.noCache()).isTrue();
    assertThat(cacheControl.noStore()).isTrue();
}