The image pipeline uses the HttpURLConnection
networking library bundled with Android.
HttpURLConnection connection.setRequestProperty("Charset", "utf-8");
Fresco: How to add RequestProperty to the ImageRequestBuilder?
The image pipeline uses the HttpURLConnection
networking library bundled with Android.
HttpURLConnection connection.setRequestProperty("Charset", "utf-8");
Fresco: How to add RequestProperty to the ImageRequestBuilder?
If you are talking about request headers, Here is what I have done in my app
DiskCacheConfig mainDiskCacheConfig = DiskCacheConfig.newBuilder()
.setBaseDirectoryPath(sContext.getCacheDir())
.setBaseDirectoryName("cache")
.setMaxCacheSize(1024 * 1024 * 1024) // max cache size
.setMaxCacheSizeOnLowDiskSpace(50 * 1024 * 1024) // for low disk cache
.setMaxCacheSizeOnVeryLowDiskSpace(10 * 1024 * 1024) // for
.build();
OkHttpClient client = new OkHttpClient();
client.interceptors().add(new Interceptor() {
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Request originalRequest = chain.request(); //Current Request
com.squareup.okhttp.Request requestWithToken = null; //The request with the access token which we will use if we have one instead of the original
requestWithToken = originalRequest.newBuilder()
.addHeader(Constant.AUTH_HEADER, BackgroundService.getAuthenticationHeader())
.addHeader(Constant.X_USER_ID, Wrapper.getInstance().getUserId())
.addHeader(Constant.X_DEVICE_KEY, DeviceUtils.getDeviceDetails(App.this).getAndroid_id())
.addHeader(Constant.X_ACCEPT_LANGUAGE, Constant.ACCEPT_LANGUAGE_ENGLISH)
.build();
Response response = chain.proceed((requestWithToken != null ? requestWithToken : originalRequest)); //proceed with the request and get the response
if (response != null && response.code() != HttpURLConnection.HTTP_OK) {
response.body().close();
}
return response;
}
});
ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(this, client)
.setMainDiskCacheConfig(mainDiskCacheConfig)
.build();
Fresco.initialize(this, config);