A dictionary of additional headers to send with requests.
- iOS 7.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
This property specifies additional headers that are added to all tasks within sessions based on this configuration. For example, you might set the
User-Agent header so that it is automatically included in every request your app makes through sessions based on this configuration.
NSURLSession object is designed to handle various aspects of the HTTP protocol for you. As a result, you should not modify the following headers:
Additionally, if the length of your upload body data can be determined automatically—for example, if you provide the body content with an NSData object—the value of
Content-Length is set for you.
If the same header appears in both this array and the request object (where applicable), the request object’s value takes precedence.
The default value is an empty array.