Contents

httpAdditionalHeaders

A dictionary of additional headers to send with requests.

Declaration

var httpAdditionalHeaders: [AnyHashable : Any]? { get set }

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 URLSession 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