Instance Property

HTTPAdditionalHeaders

A dictionary of additional headers to send with requests.

Declaration

@property(copy) NSDictionary *HTTPAdditionalHeaders;

Discussion

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.

An NSURLSession object is designed to handle various aspects of the HTTP protocol for you. As a result, you should not modify the following headers:

  • Authorization

  • Connection

  • Host

  • Proxy-Authenticate

  • Proxy-Authorization

  • WWW-Authenticate

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.

See Also

Setting General Properties

identifier

The background session identifier of the configuration object.

networkServiceType

The type of network service for all tasks within sessions based on this configuration.

allowsCellularAccess

A Boolean value that determines whether connections should be made over a cellular network.

timeoutIntervalForRequest

The timeout interval to use when waiting for additional data.

timeoutIntervalForResource

The maximum amount of time that a resource request should be allowed to take.

sharedContainerIdentifier

The identifier for the shared container into which files in background URL sessions should be downloaded.

waitsForConnectivity

A Boolean value that indicates whether the session should wait for connectivity to become available, or fail immediately.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software