描述
这里是Android上的协议字符串拼接:
https://github.com/zxcpoiu/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java#L110
这里有一个来自Websocket库的相同逻辑:
https://github.com/theturtle32/WebSocket-Node/blob/master/lib/WebSocketClient.js#L200C53-L200C62****
我不确定这是否违反了RFC: https://www.rfc-editor.org/rfc/rfc6455
因为它不规范,所以它确实会破坏一些服务器。特别是Deepgram Websocket服务器在Android上失败,但在iOS上工作。
重现步骤
yarn run
React Native版本
0.73.0
受影响的平台
运行时 - Android
npx react-native info
的输出
System:
OS: macOS 14.2.1
CPU: (10) arm64 Apple M1 Pro
Memory: 113.02 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.20.2
path: /usr/local/bin/node
Yarn:
version: 1.22.22
path: ~/Documents/GitHub/app/node_modules/.bin/yarn
npm:
version: 10.5.0
path: /usr/local/bin/npm
Watchman:
version: 2024.03.25.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /Users/admin/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.5
- iOS 17.5
- macOS 14.5
- tvOS 17.5
- visionOS 1.2
- watchOS 10.5
Android SDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9477386
Xcode:
version: 15.4/15F31d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.18
path: /usr/bin/javac
Ruby:
version: 2.7.6
path: /Users/admin/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react: Not Found
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
info React Native v0.74.2 is now available (your project is running on v0.72.8).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.74.2
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.72.8
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
堆栈跟踪或日志
// @ts-ignore
this._socket = new WebSocket(url.toString(), null, {
headers: {
'Sec-WebSocket-Protocol': ['token', this.key].join(', '),
},
});
重现者
https://github.com/react-native-community/reproducer-react-native
截图和视频
- 无响应*
5条答案
按热度按时间qncylg1j1#
hs1rzwqc2#
pn9klfpd3#
我不确定这是否违反了RFC:rfc-editor.org/rfc/rfc6455
你能具体指出我们在RFC中违反了什么吗?
0mkxixxg4#
正如我上面所说,我不确定这是否违反了RFC,只是与其他WebSocket客户端库(包括React-Native的iOS库)使用的约定不匹配。我认为这个相关的RFC是:
https://www.rfc-editor.org/rfc/rfc2616#section-4.2
"如果且仅当整个字段值被定义为逗号分隔列表(即#(values)),则消息中可以存在具有相同字段名的多个消息头字段。它必须能够将多个头字段组合成一个“字段名:字段值”对,而不会改变消息的语义,方法是将每个后续字段值附加到第一个字段值上,每个字段值之间用逗号分隔。"
RFC似乎更多地是一个建议,它只是说要使用“,”,但没有提到添加空格“,”。
vhmi4jdf5#
RFC似乎更像是一个建议,它只是说要使用一个逗号,但没有提到在
,
后面添加空格会破坏规范。是的,这是一个有点弱的说法。如果你能提供更多证据表明在
,
后面添加空格会破坏规范,我们可能会考虑改变它。