Skip to content

Commit e59d633

Browse files
cortinicometa-codesync[bot]
authored andcommitted
Apply custom headers in RCTCxxInspectorWebSocketAdapter (#55612)
Summary: Pull Request resolved: #55612 Inject custom devsupport headers into the inspector CDP WebSocket connection. Changes from `initWithURL:` to `initWithURLRequest:` so headers can be set on the HTTP upgrade handshake. Changelog: [Internal] [Changed] - Reviewed By: cipolleschi Differential Revision: D93596715 fbshipit-source-id: 12dc5c991027654fdd5559daafbc27144a0fdb6b
1 parent d073182 commit e59d633

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/react-native/React/Inspector/RCTCxxInspectorWebSocketAdapter.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#if RCT_DEV || RCT_REMOTE_PROFILE
1111

1212
#import <React/RCTAssert.h>
13+
#import <React/RCTDevSupportHttpHeaders.h>
1314
#import <React/RCTInspector.h>
1415
#import <React/RCTInspectorPackagerConnection.h>
1516
#import <React/RCTUtils.h>
@@ -40,7 +41,10 @@ - (instancetype)initWithURL:(const std::string &)url delegate:(std::weak_ptr<IWe
4041
{
4142
if ((self = [super init]) != nullptr) {
4243
_delegate = delegate;
43-
_webSocket = [[SRWebSocket alloc] initWithURL:[NSURL URLWithString:NSStringFromUTF8StringView(url)]];
44+
NSURL *requestURL = [NSURL URLWithString:NSStringFromUTF8StringView(url)];
45+
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL];
46+
[[RCTDevSupportHttpHeaders sharedInstance] applyHeadersToRequest:request];
47+
_webSocket = [[SRWebSocket alloc] initWithURLRequest:request];
4448
_webSocket.delegate = self;
4549
[_webSocket open];
4650
}

0 commit comments

Comments
 (0)