diff --git a/Libraries/Network/RCTNetworking.ios.js b/Libraries/Network/RCTNetworking.ios.js index b67049036..dd569a07d 100644 --- a/Libraries/Network/RCTNetworking.ios.js +++ b/Libraries/Network/RCTNetworking.ios.js @@ -33,7 +33,8 @@ class RCTNetworking extends NativeEventEmitter { responseType: 'text' | 'base64', incrementalUpdates: boolean, timeout: number, - callback: (requestId: number) => any + callback: (requestId: number) => any, + withCredentials: boolean ) { const body = convertRequestBody(data); RCTNetworkingNative.sendRequest({ @@ -43,7 +44,8 @@ class RCTNetworking extends NativeEventEmitter { headers, responseType, incrementalUpdates, - timeout + timeout, + withCredentials }, callback); } diff --git a/Libraries/Network/RCTNetworking.mm b/Libraries/Network/RCTNetworking.mm index 67379f96b..4a7f7ccd6 100644 --- a/Libraries/Network/RCTNetworking.mm +++ b/Libraries/Network/RCTNetworking.mm @@ -230,6 +230,7 @@ RCT_EXPORT_MODULE() request.HTTPMethod = [RCTConvert NSString:RCTNilIfNull(query[@"method"])].uppercaseString ?: @"GET"; request.allHTTPHeaderFields = [self stripNullsInRequestHeaders:[RCTConvert NSDictionary:query[@"headers"]]]; request.timeoutInterval = [RCTConvert NSTimeInterval:query[@"timeout"]]; + request.HTTPShouldHandleCookies = [RCTConvert BOOL:query[@"withCredentials"]]; NSDictionary *data = [RCTConvert NSDictionary:RCTNilIfNull(query[@"data"])]; NSString *trackingName = data[@"trackingName"]; if (trackingName) { diff --git a/Libraries/Network/XMLHttpRequest.js b/Libraries/Network/XMLHttpRequest.js index c0f2be923..92669b8b2 100644 --- a/Libraries/Network/XMLHttpRequest.js +++ b/Libraries/Network/XMLHttpRequest.js @@ -119,6 +119,7 @@ class XMLHttpRequest extends EventTarget(...XHR_EVENTS) { status: number = 0; timeout: number = 0; responseURL: ?string; + withCredentials: boolean = false upload: XMLHttpRequestEventTarget = new XMLHttpRequestEventTarget(); @@ -501,6 +502,7 @@ class XMLHttpRequest extends EventTarget(...XHR_EVENTS) { incrementalEvents, this.timeout, this.__didCreateRequest.bind(this), + this.withCredentials ); }