Contents

CFHTTPMessageCopyAllHeaderFields(_:)

Gets all header fields from a CFHTTPMessage object.

Declaration

func CFHTTPMessageCopyAllHeaderFields(_ message: CFHTTPMessage) -> Unmanaged<CFDictionary>?

Parameters

  • message:

    The message to examine.

Return Value

A CFDictionaryRef object containing keys and values that are CFStringRef objects, where the key is the header fieldname and the dictionary value is the header field’s value. Returns NULL if the header fields could not be copied. Ownership follows the The Create Rule.

Discussion

HTTP headers are case insensitive. To simplify your code, certain header field names are canonicalized into their standard form. For example, if the server sends a content-length header, it is automatically adjusted to be Content-Length.

The returned dictionary of headers is configured to be case-preserving during the set operation (unless the key already exists with a different case), and case-insensitive when looking up keys.

For example, if you set the header X-foo, and then later set the header X-Foo, the dictionary’s key will be X-foo, but the value will taken from the X-Foo header.

See Also

HTTP Messages