Skip to content

Commit 05a3851

Browse files
Riccardo Cipolleschimeta-codesync[bot]
authored andcommitted
Apply custom dev support headers to iOS WebSocket connections
Summary: ## Summary: Apply custom HTTP headers from `RCTDevSupportHttpHeaders` to all WebSocket connections created by `RCTWebSocketModule`. This ensures that auth tokens and other custom headers configured via the dev support header API are included in WebSocket upgrade requests. ## Changelog: [IOS][CHANGED] - Apply custom dev support HTTP headers to WebSocket connections ## Test Plan: Verified that the `RCTDevSupportHttpHeaders` singleton is called to apply headers to the mutable URL request before creating the SRWebSocket instance. ## Facebook: Applied from nest/mobile/apps/atod-sample/patches/react-native+0.83.1+005+atod-websocket-ios.patch Differential Revision: D95037876
1 parent 8a5c3b4 commit 05a3851

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/react-native/React/CoreModules/RCTWebSocketModule.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import <FBReactNativeSpec/FBReactNativeSpec.h>
1313
#import <React/RCTAssert.h>
1414
#import <React/RCTConvert.h>
15+
#import <React/RCTDevSupportHttpHeaders.h>
1516
#import <React/RCTUtils.h>
1617
#import <SocketRocket/SRWebSocket.h>
1718

@@ -114,6 +115,8 @@ - (void)invalidate
114115
}];
115116
}
116117

118+
[[RCTDevSupportHttpHeaders sharedInstance] applyHeadersToRequest:request];
119+
117120
SRWebSocket *webSocket = [[SRWebSocket alloc] initWithURLRequest:request protocols:protocols];
118121
[webSocket setDelegateDispatchQueue:[self methodQueue]];
119122
webSocket.delegate = self;

0 commit comments

Comments
 (0)