Skip to content

Commit

Permalink
fix(android): default UA (#3429)
Browse files Browse the repository at this point in the history
* Update DataSourceUtil.java

* fix(android): default UA
  • Loading branch information
lovegaoshi committed Dec 20, 2023
1 parent c8983f4 commit dd7bb54
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,16 @@ private static HttpDataSource.Factory buildHttpDataSourceFactory(ReactContext co
ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
container.setCookieJar(new JavaNetCookieJar(handler));
OkHttpDataSource.Factory okHttpDataSourceFactory = new OkHttpDataSource.Factory((Call.Factory) client)
.setUserAgent(getUserAgent(context))
.setTransferListener(bandwidthMeter);

if (requestHeaders != null)
if (requestHeaders != null) {
okHttpDataSourceFactory.setDefaultRequestProperties(requestHeaders);
if (!requestHeaders.containsKey("User-Agent")) {
okHttpDataSourceFactory.setUserAgent(getUserAgent(context));
}
} else {
okHttpDataSourceFactory.setUserAgent(getUserAgent(context));
}

return okHttpDataSourceFactory;
}
Expand Down

0 comments on commit dd7bb54

Please sign in to comment.