mirror of
https://github.com/status-im/react-native-webview.git
synced 2026-08-31 03:31:05 +00:00
fix(iOS): Send cookies with resource requests (#1803)
* iOS cookie available for resource requests * Missig brace added Co-authored-by: niwani <niwani@microsoft.com>
This commit is contained in:
@@ -543,6 +543,16 @@ static NSDictionary* customCertificatesForHost;
|
||||
}
|
||||
[_webView loadHTMLString:html baseURL:baseURL];
|
||||
return;
|
||||
}
|
||||
//Add cookie for subsequent resource requests sent by page itself, if cookie was set in headers on WebView
|
||||
NSString *headerCookie = [RCTConvert NSString:_source[@"headers"][@"cookie"]];
|
||||
if(headerCookie) {
|
||||
NSDictionary *headers = [NSDictionary dictionaryWithObjectsAndKeys:headerCookie,@"Set-Cookie",nil];
|
||||
NSURL *urlString = [NSURL URLWithString:_source[@"uri"]];
|
||||
NSArray *httpCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:headers forURL:urlString];
|
||||
for (NSHTTPCookie *httpCookie in httpCookies) {
|
||||
[_webView.configuration.websiteDataStore.httpCookieStore setCookie:httpCookie completionHandler:nil];
|
||||
}
|
||||
}
|
||||
|
||||
NSURLRequest *request = [self requestForSource:_source];
|
||||
|
||||
Reference in New Issue
Block a user