Skip to content
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

[Android][Websockets] - Origin header check shouldn't be case sensitive #27827

Closed
wants to merge 3 commits into from

Conversation

brunobar79
Copy link
Contributor

@brunobar79 brunobar79 commented Jan 21, 2020

Summary

Based on this, header names are not case sensitive.
That means that it's valid to pass a header Origin or origin.

With the current implementation. on Android only, if you pass Origin, it will get overwritten by the default origin.

This made me waste a lot of time debugging a problem while trying to connect to a websockets server that required an origin header and my implementation was working fine in iOS but not on Android, so I'm suggest changing the logic a little bit to take that into account.

Changelog

[Android] [Fixed] - Support for case insensitive "Origin" headers for Websockets

Test Plan

Here's a screenshot of that shows the issue before the fix (Origin header set, but getting overridden)

Screen Shot 2020-01-21 at 11 41 33 AM

The fix is not that easy to test since it requires a public websocket server that checks for a custom Origin header, but I think the code changes are very small and clear.

@facebook-github-bot facebook-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 Jan 21, 2020
@brunobar79 brunobar79 changed the title Patch 1 [Android][Websockets] - Origin header check should be case insensitive Jan 21, 2020
@react-native-bot react-native-bot added Platform: Android Android applications. Bug labels Jan 21, 2020
@brunobar79 brunobar79 changed the title [Android][Websockets] - Origin header check should be case insensitive [Android][Websockets] - Origin header check shouldn't be case sensitive Jan 21, 2020
Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

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

This makes sense, thank you!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @brunobar79 in aeaf286.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Jan 27, 2020
osdnk pushed a commit to osdnk/react-native that referenced this pull request Mar 9, 2020
Summary:
Based on [this](https://stackoverflow.com/a/5259004), header names are not case sensitive.
That means that it's valid to pass a header `Origin` or `origin`.

With the current implementation. on Android only, if you pass `Origin`, it will get overwritten by the default origin.

This made me waste a lot of time debugging a problem while trying to connect to a websockets server that required an `origin` header and my implementation was working fine in iOS but not on Android, so I'm suggest changing the logic a little bit to take that into account.

## Changelog

[Android] [Fixed] - Support for case insensitive "Origin" headers for Websockets
Pull Request resolved: facebook#27827

Test Plan:
Here's a screenshot of that shows the issue before the fix (`Origin` header set, but getting overridden)

![Screen Shot 2020-01-21 at 11 41 33 AM](https://user-images.githubusercontent.com/1247834/72824606-86302900-3c43-11ea-92c2-3d39881495f0.png)

The fix is not that easy to test since it requires a public websocket server that checks for a custom Origin header, but I think the code changes are very small and clear.

Differential Revision: D19578860

Pulled By: cpojer

fbshipit-source-id: d854e887d1b9e8e54da662b2da2ebe08ce65fdbc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants