Commit 72b7970
Add SRWebSocketProvider for selective WebSocket header injection
Summary:
## Summary:
Replace the blind application of dev headers on all WebSocket connections with
a provider pattern that mirrors RCTHTTPRequestHandler's
NSURLSessionConfigurationProvider. A custom `SRWebSocketProvider` block can be
registered via `RCTSetCustomSRWebSocketProvider` to intercept WebSocket
creation and selectively modify the request (e.g. injecting auth headers) for
specific endpoints. If no provider is set, or if the provider returns nil,
the default SRWebSocket creation logic is used.
- Declare `SRWebSocketProvider` typedef and `RCTSetCustomSRWebSocketProvider`
in RCTWebSocketModule.h
- Implement the provider hook in RCTWebSocketModule.mm
- Remove the previous blind `RCTDevSupportHttpHeaders` application
## Changelog:
[IOS][CHANGED] - Add SRWebSocketProvider for selective WebSocket header injection
## Test Plan:
Verified that the `SRWebSocketProvider` block is called when registered, and
that returning nil falls back to the default SRWebSocket creation. When no
provider is registered, behavior is unchanged from before.
## Facebook:
Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+005+atod-websocket-ios.patch
Differential Revision: D950378761 parent 9678da5 commit 72b7970
File tree
2 files changed
+20
-1
lines changed- packages/react-native/React/CoreModules
2 files changed
+20
-1
lines changedLines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| |||
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
114 | 121 | | |
115 | 122 | | |
116 | 123 | | |
117 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
118 | 131 | | |
119 | 132 | | |
120 | 133 | | |
| |||
0 commit comments