Skip to content

Apply User-Agent header correctly to Android WebView - #5822

Closed
mtostenson wants to merge 2 commits into
react:masterfrom
mtostenson:user-agent
Closed

Apply User-Agent header correctly to Android WebView#5822
mtostenson wants to merge 2 commits into
react:masterfrom
mtostenson:user-agent

Conversation

@mtostenson

Copy link
Copy Markdown

@facebook-github-bot

Copy link
Copy Markdown
Contributor

By analyzing the blame information on this pull request, we identified @mtostenson, @mkonicek and @nicklockwood to be potential reviewers.

@facebook-github-botfacebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Feb 8, 2016
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mtostenson updated the pull request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use case-insensitive comparison

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mtostenson updated the pull request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can view.getSettings() return null, causing a NPE?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just discovered that useragent is already it's own prop, I think I'll handle this case where the user agent is provided in the headers in the wrapper, and just pass it along to the user agent prop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, sounds good!

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mtostenson updated the pull request.

@mkonicek

Copy link
Copy Markdown
Contributor

@mtostenson Do you still want to make changes based on the comments above or is this good to go?

@ghost

ghost commented Apr 1, 2016

Copy link
Copy Markdown

@mkonicek would you mind taking a look at this pull request? It's been a while since the last commit was reviewed.

@mtostenson

Copy link
Copy Markdown
Author

@mkonicek I'm starting to think this change isn't necessary.
In my particular use case, I had the user-agent string being included with the rest of the headers, but I should probably just use the prop. I think I'll close this unless you think differently.

@janicduplessis

Copy link
Copy Markdown
Contributor

I think the user agent header should either work or warn to use the user agent prop. It will avoid any confusion around it.

@mkonicek

Copy link
Copy Markdown
Contributor

It is a indeed quite confusing the user agent header is set using a prop.

Thanks for the ping, I think this PR will reduce the confusion actually. Let's merge it.

@facebook-github-bot shipit

@facebook-github-bot

Copy link
Copy Markdown
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@mkonicek

Copy link
Copy Markdown
Contributor

@mtostenson The patch doesn't apply anymore. Could you rebase please?

@mkonicek

Copy link
Copy Markdown
Contributor

Can you please also add a Test plan showing how you verified the code fixes the issue? See https://github.com/facebook/react-native/blob/master/PULL_REQUEST_TEMPLATE.md

@mtostenson

Copy link
Copy Markdown
Author

@mkonicek I just rebased and tested. Unfortunately, that link appears to be dead. Were you pointing me to this perhaps? https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md

@ghostghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 12, 2016
@ghostghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 21, 2016
@facebook-github-botfacebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 11, 2016
@ghostghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 11, 2016
@mkonicek

mkonicek commented Oct 26, 2016

Copy link
Copy Markdown
Contributor

@mtostenson You commented in the past:

I just discovered that useragent is already it's own prop, I think I'll handle this case where the user agent is provided in the headers in the wrapper, and just pass it along to the user agent prop.

Do you still want to do that? I think you mean this?

<WebView
userAgent='MyApp'
source={{uri:this.state.url}} />

Someone said the userAgent prop works on both iOS and Android:
#5821

It is documented for Android: http://facebook.github.io/react-native/docs/webview.html#useragent

So I think we can close this PR.

Sorry about the broken link, the pull request template has been moved, see this for an explanation of how to write a Test Plan: https://github.com/facebook/react-native/blob/master/.github/PULL_REQUEST_TEMPLATE.md

import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.*;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no wildcard imports.

@mkonicek

Copy link
Copy Markdown
Contributor

Sorry this took so long, I was on a different team and Github notifications fell through the cracks :(

@mkonicek

mkonicek commented Oct 26, 2016

Copy link
Copy Markdown
Contributor

I'll make a change internally that still sets the user agent based on the header too, addressing the nits on this PR.

@mkonicek

Copy link
Copy Markdown
Contributor

Followup PR: #10563

facebook-github-bot pushed a commit that referenced this pull request Oct 26, 2016
Summary:
Followup for #5822, addressing nits.
**Test Plan**
Travis CI (the author of #5822 tested the change).
Closes#10563
Differential Revision: D4081826
fbshipit-source-id: f3a2e1996bf02f81fecea6e53fe1c522b8c85689
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@mtostenson@facebook-github-bot@mkonicek@janicduplessis@ide@fredemmott@satya164