use of okhttp3.CacheControl in project sonarqube by SonarSource.
the class HttpHeadersTest method assertCacheInBrowser.
private static void assertCacheInBrowser(Response httpResponse) {
CacheControl cacheControl = httpResponse.cacheControl();
assertThat(cacheControl.mustRevalidate()).isFalse();
assertThat(cacheControl.noCache()).isFalse();
assertThat(cacheControl.noStore()).isFalse();
}
use of okhttp3.CacheControl in project sonarqube by SonarSource.
the class HttpHeadersTest method assertNoCacheInBrowser.
private static void assertNoCacheInBrowser(Response httpResponse) {
CacheControl cacheControl = httpResponse.cacheControl();
assertThat(cacheControl.mustRevalidate()).isTrue();
assertThat(cacheControl.noCache()).isTrue();
assertThat(cacheControl.noStore()).isTrue();
}
use of okhttp3.CacheControl in project Lightning-Browser by anthonycr.
the class BaseSuggestionsModel method downloadSuggestionsForQuery.
/**
* This method downloads the search suggestions for the specific query.
* NOTE: This is a blocking operation, do not getResults on the UI thread.
*
* @param query the query to get suggestions for
* @return the cache file containing the suggestions
*/
@Nullable
private InputStream downloadSuggestionsForQuery(@NonNull String query, @NonNull String language) {
String queryUrl = createQueryUrl(query, language);
try {
URL url = new URL(queryUrl);
// OkHttp automatically gzips requests
Request suggestionsRequest = new Request.Builder().url(url).addHeader("Accept-Charset", mEncoding).cacheControl(mCacheControl).build();
Response suggestionsResponse = mHttpClient.newCall(suggestionsRequest).execute();
ResponseBody responseBody = suggestionsResponse.body();
return responseBody != null ? responseBody.byteStream() : null;
} catch (IOException exception) {
Log.e(TAG, "Problem getting search suggestions", exception);
}
return null;
}
use of okhttp3.CacheControl in project apps-android-wikipedia by wikimedia.
the class StripMustRevalidateResponseInterceptor method intercept.
@Override
public Response intercept(@NonNull Interceptor.Chain chain) throws IOException {
Response rsp = chain.proceed(chain.request());
HttpUrl url = rsp.request().url();
if (HttpUrlUtil.isRestBase(url) || HttpUrlUtil.isMobileView(url)) {
String cacheControl = CacheControlUtil.removeDirective(rsp.cacheControl().toString(), "must-revalidate");
rsp = rsp.newBuilder().header("Cache-Control", cacheControl).build();
}
return rsp;
}
use of okhttp3.CacheControl in project instructure-android by instructure.
the class MobileVerifyAPI method getAuthenticationRetrofit.
private static Retrofit getAuthenticationRetrofit() {
final String userAgent = ApiPrefs.getUserAgent();
OkHttpClient httpClient = new OkHttpClient.Builder().addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
if (!userAgent.equals("")) {
Request request = chain.request().newBuilder().header("User-Agent", userAgent).cacheControl(CacheControl.FORCE_NETWORK).build();
return chain.proceed(request);
} else {
return chain.proceed(chain.request());
}
}
}).build();
return new Retrofit.Builder().baseUrl("https://canvas.instructure.com/api/v1/").client(httpClient).addConverterFactory(GsonConverterFactory.create()).build();
}
Aggregations