Use a dictionary containing authentication credentials to perform the authentication method specified by a CFHTTPAuthentication object.


func CFHTTPMessageApplyCredentialDictionary(_ request: CFHTTPMessage, _ auth: CFHTTPAuthentication, _ dict: CFDictionary, _ error: UnsafeMutablePointer<CFStreamError>?) -> Bool



The request for which the authentication method is to be performed.


A CFHTTPAuthentication object specifying the authentication method to perform.


A dictionary containing authentication credentials to be applied to the request. For information on the keys in this dictionary, see CFHTTPAuthentication.


If an error occurs, upon return contains a CFStreamError object that describes the error and the error’s domain. Pass NULL if you don’t want to receive error information.

Return Value

TRUE if the authentication was successful, otherwise, FALSE.


This function performs the authentication method specified by auth on behalf of the request specified by request using the credentials contained in the dictionary specified by dict. The dictionary must contain values for the kCFHTTPAuthenticationUsername and kCFHTTPAuthenticationPassword keys. If CFHTTPAuthenticationRequiresAccountDomain(_:) returns TRUE for auth, the dictionary must also contain a value for the kCFHTTPAuthenticationAccountDomain key.

Special Considerations

This function is thread safe as long as another thread does not alter the same CFHTTPAuthentication object at the same time.

See Also

HTTP Messages

class CFHTTPMessage

An opaque reference representing an HTTP message.

func CFHTTPMessageCopyBody(CFHTTPMessage) -> Unmanaged<CFData>?

Gets the body from a CFHTTPMessage object.

func CFHTTPMessageCopyHeaderFieldValue(CFHTTPMessage, CFString) -> Unmanaged<CFString>?

Gets the value of a header field from a CFHTTPMessage object.

func CFHTTPMessageCopyRequestMethod(CFHTTPMessage) -> Unmanaged<CFString>?

Gets the request method from a CFHTTPMessage object.

func CFHTTPMessageCopyVersion(CFHTTPMessage) -> Unmanaged<CFString>

Gets the HTTP version from a CFHTTPMessage object.

func CFHTTPMessageCreateEmpty(CFAllocator?, Bool) -> Unmanaged<CFHTTPMessage>

Creates and returns a new, empty CFHTTPMessage object.

func CFHTTPMessageGetResponseStatusCode(CFHTTPMessage) -> CFIndex

Gets the status code from a CFHTTPMessage object representing an HTTP response.

func CFHTTPMessageGetTypeID() -> CFTypeID

Returns the Core Foundation type identifier for the CFHTTPMessage opaque type.

func CFHTTPMessageIsHeaderComplete(CFHTTPMessage) -> Bool

Determines whether a message header is complete.

func CFHTTPMessageIsRequest(CFHTTPMessage) -> Bool

Returns a Boolean indicating whether the HTTP message is a request or a response.

func CFHTTPMessageSetBody(CFHTTPMessage, CFData)

Sets the body of a CFHTTPMessage object.

func CFHTTPMessageSetHeaderFieldValue(CFHTTPMessage, CFString, CFString?)

Sets the value of a header field in an HTTP message.

let kCFHTTPVersion1_0: CFString

Specifies HTTP version 1.0.

let kCFHTTPVersion1_1: CFString

Specifies HTTP version 1.1.