Commit a2efa20
Add SRWebSocketProvider for selective WebSocket header injection (facebook#55870)
Summary:
Pull Request resolved: facebook#55870
## 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
Reviewed By: cortinico
Differential Revision: D95037876
fbshipit-source-id: 8e721397802db6eac9df686b0d064f597747a7461 parent 6401e73 commit a2efa20
2 files changed
Lines changed: 20 additions & 1 deletion
Lines 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