Created
December 28, 2019 18:56
-
-
Save IsaAliev/236abd3f8f9751b79f1527215ed4f326 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) { | |
guard let newRequest = (request as NSURLRequest).mutableCopy() as? NSMutableURLRequest else { | |
completionHandler(request) | |
return | |
} | |
if let cookies = HTTPCookieStorage.shared.cookies { | |
newRequest.allHTTPHeaderFields = HTTPCookie.requestHeaderFields(with: cookies) | |
completionHandler(newRequest as URLRequest) | |
return | |
} | |
completionHandler(request) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment