Followup: Apply the User-Agent header correctly to Android WebView
Summary: Followup for #5822, addressing nits. **Test Plan** Travis CI (the author of #5822 tested the change). Closes https://github.com/facebook/react-native/pull/10563 Differential Revision: D4081826 fbshipit-source-id: f3a2e1996bf02f81fecea6e53fe1c522b8c85689
This commit is contained in:
parent
dc02907039
commit
b28c0bb7db
|
@ -13,6 +13,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import android.content.Intent;
|
||||
|
@ -428,7 +429,13 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
|||
ReadableMapKeySetIterator iter = headers.keySetIterator();
|
||||
while (iter.hasNextKey()) {
|
||||
String key = iter.nextKey();
|
||||
headerMap.put(key, headers.getString(key));
|
||||
if ("user-agent".equals(key.toLowerCase(Locale.ENGLISH))) {
|
||||
if (view.getSettings() != null) {
|
||||
view.getSettings().setUserAgentString(headers.getString(key));
|
||||
}
|
||||
} else {
|
||||
headerMap.put(key, headers.getString(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
view.loadUrl(url, headerMap);
|
||||
|
|
Loading…
Reference in New Issue