Instance Method


Sets a value for the header field.


mutating func setValue(_ value: String?, forHTTPHeaderField field: String)



The new value for the header field. Any existing value for the field is replaced by the new value.


The name of the header field to set. In keeping with the HTTP RFC, HTTP header field names are case insensitive.


Certain header fields are reserved. Do not use this method to set such headers. Specifically, there is no need for you to set the Content-Length header. See Reserved HTTP Headers.

See Also

Accessing Header Fields

var allHTTPHeaderFields: [String : String]?

A dictionary containing all of the HTTP header fields for a request.

func addValue(String, forHTTPHeaderField: String)

Adds a value to the header field.

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