com.facebook.react.modules.network.ForwardingCookieHandler Java Examples

The following examples show how to use com.facebook.react.modules.network.ForwardingCookieHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FrescoModule.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Get the default Fresco configuration builder.
 * Allows adding of configuration options in addition to the default values.
 *
 * @return {@link ImagePipelineConfig.Builder} that has been initialized with default values
 */
public static ImagePipelineConfig.Builder getDefaultConfigBuilder(ReactContext context) {
  HashSet<RequestListener> requestListeners = new HashSet<>();
  requestListeners.add(new SystraceRequestListener());

  OkHttpClient client = OkHttpClientProvider.createClient();

  // make sure to forward cookies for any requests via the okHttpClient
  // so that image requests to endpoints that use cookies still work
  CookieJarContainer container = (CookieJarContainer) client.cookieJar();
  ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
  container.setCookieJar(new JavaNetCookieJar(handler));

  return OkHttpImagePipelineConfigFactory
    .newBuilder(context.getApplicationContext(), client)
    .setNetworkFetcher(new ReactOkHttpNetworkFetcher(client))
    .setDownsampleEnabled(false)
    .setRequestListeners(requestListeners);
}
 
Example #2
Source File: DataSourceUtil.java    From react-native-video with MIT License 5 votes vote down vote up
private static HttpDataSource.Factory buildHttpDataSourceFactory(ReactContext context, DefaultBandwidthMeter bandwidthMeter, Map<String, String> requestHeaders) {
    OkHttpClient client = OkHttpClientProvider.getOkHttpClient();
    CookieJarContainer container = (CookieJarContainer) client.cookieJar();
    ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
    container.setCookieJar(new JavaNetCookieJar(handler));
    OkHttpDataSourceFactory okHttpDataSourceFactory = new OkHttpDataSourceFactory(client, getUserAgent(context), bandwidthMeter);

    if (requestHeaders != null)
        okHttpDataSourceFactory.getDefaultRequestProperties().set(requestHeaders);

    return okHttpDataSourceFactory;
}
 
Example #3
Source File: CookieManagerModule.java    From imsdk-android with MIT License 4 votes vote down vote up
public CookieManagerModule(ReactApplicationContext context) {
    super(context);
    this.cookieHandler = new ForwardingCookieHandler(context);
}
 
Example #4
Source File: WebSocketModule.java    From react-native-GPay with MIT License 4 votes vote down vote up
public WebSocketModule(ReactApplicationContext context) {
  super(context);
  mReactContext = context;
  mCookieHandler = new ForwardingCookieHandler(context);
}
 
Example #5
Source File: RNTurbolinksModule.java    From react-native-turbolinks with MIT License 4 votes vote down vote up
@ReactMethod
public void removeAllCookies() {
    new ForwardingCookieHandler(getReactApplicationContext()).clearCookies(new Callback() {
        public void invoke(Object... args) {}
    });
}