Skip to content

Commit

Permalink
Fixes NetowrkingModule construction with interceptors
Browse files Browse the repository at this point in the history
Reviewed By: andreicoman11

Differential Revision: D3316229

fbshipit-source-id: 0dc5cce68b6649ebd2ff44c313ab94a0f5a06f66
  • Loading branch information
bestander authored and Facebook Github Bot 2 committed May 18, 2016
1 parent 061151c commit 921d0de
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
OkHttpClient client,
@Nullable List<NetworkInterceptorCreator> networkInterceptorCreators) {
super(reactContext);
mClient = client;

if (networkInterceptorCreators != null) {
OkHttpClient.Builder clientBuilder = client.newBuilder();
for (NetworkInterceptorCreator networkInterceptorCreator : networkInterceptorCreators) {
mClient.networkInterceptors().add(networkInterceptorCreator.create());
clientBuilder.addNetworkInterceptor(networkInterceptorCreator.create());
}
client = clientBuilder.build();
}
mClient = client;
OkHttpClientProvider.replaceOkHttpClient(client);
mCookieHandler = new ForwardingCookieHandler(reactContext);
mCookieJarContainer = (CookieJarContainer) mClient.cookieJar();
mShuttingDown = false;
Expand All @@ -87,7 +91,7 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
* caller does not provide one explicitly
* @param client the {@link OkHttpClient} to be used for networking
*/
public NetworkingModule(
/* package */ NetworkingModule(
ReactApplicationContext context,
@Nullable String defaultUserAgent,
OkHttpClient client) {
Expand Down Expand Up @@ -121,10 +125,6 @@ public NetworkingModule(ReactApplicationContext context, String defaultUserAgent
this(context, defaultUserAgent, OkHttpClientProvider.getOkHttpClient(), null);
}

public NetworkingModule(ReactApplicationContext reactContext, OkHttpClient client) {
this(reactContext, null, client, null);
}

@Override
public void initialize() {
mCookieJarContainer.setCookieJar(new JavaNetCookieJar(mCookieHandler));
Expand Down

0 comments on commit 921d0de

Please sign in to comment.