Converts an array of cookies to a dictionary of header fields.
SDKs
- iOS 2.0+
- macOS 10.2+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
class func requestHeaderFields(with cookies: [HTTPCookie]) -> [String : String]
Parameters
cookies
The cookies from which the header fields are created.
Return Value
The dictionary of header fields created from the provided cookies.
Discussion
To send these headers as part of a URL request to a remote server, create an NSMutable
object, then call the all
or set
method to set the provided headers for the request. Finally, initialize and start an URLSession
instance based on that request object.