mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 17:47:21 +08:00
Summary:
**Motivation**
Currently, when supplying a URL with protocol scheme `http` or `https` to the WebSocket module:
```
new WebSocket("http://10.0.2.2:8080")
```
it will result in the following error:

When a WebSocket URL with protocol scheme `http` or `https` is used the method [`getDefaultOrigin`](be4afdde37/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java (L274-L301)) will fail to substitute it and just returns a URL with empty protocol scheme leading to this opaque exception.
Thus, in case of `http` or `https` it should just inherit the protocol scheme since the WebSocket is responsible for upgrading the HTTP/HTTPS connection to the WebSocket protocol.
**Test plan**
If anything this change makes the method more robust. The WebSock
Closes https://github.com/facebook/react-native/pull/12713
Differential Revision: D4657738
Pulled By: ericvicenti
fbshipit-source-id: 8835b539e94713355e063a2639b7293c764b084b
Building React Native for Android
See the docs on the website.
Running tests
When you submit a pull request CircleCI will automatically run all tests. To run tests locally, see Testing.