-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(http): Apply overrideUserAgent to requests #7906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-upping my approval here. That's a heck of an android bug, but looks like it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some minor comments
android/capacitor/src/main/java/com/getcapacitor/plugin/util/HttpRequestHandler.java
Outdated
Show resolved
Hide resolved
android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java
Outdated
Show resolved
Hide resolved
android/capacitor/src/main/java/com/getcapacitor/plugin/util/HttpRequestHandler.java
Outdated
Show resolved
Hide resolved
android/capacitor/src/main/java/com/getcapacitor/plugin/util/HttpRequestHandler.java
Outdated
Show resolved
Hide resolved
// https://issues.chromium.org/issues/40450316 | ||
// x-cap-user-agent contains the user agent set in JavaScript | ||
String userAgentValue = headers.getString("x-cap-user-agent"); | ||
if (userAgentValue != null && !userAgentValue.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (userAgentValue != null && !userAgentValue.isEmpty()) { | |
if (userAgentValue != null) { |
I noticed iOS allows empty strings, so we should also allow them for Android
Take the Cap Config values of
overrideUserAgent
(orios.overrideUserAgent
|android.overrideUserAgent
) and apply them to CapacitorHttp requests. Also handles User-Agent headers set from JavaScript on Android.closes #7063