iOS Developer Library

Developer

CFHTTPMessage Reference

Options
Deployment Target:

On This Page
Language:

CFHTTPMessage Reference

The CFHTTPMessage opaque type represents an HTTP message.

Functions

  • Performs the authentication method specified by a CFHTTPAuthentication object.

    Declaration

    Swift

    func CFHTTPMessageApplyCredentials(_ request: CFHTTPMessage, _ auth: CFHTTPAuthentication, _ username: CFString?, _ password: CFString?, _ error: UnsafeMutablePointer<CFStreamError>) -> Bool

    Objective-C

    Boolean CFHTTPMessageApplyCredentials ( CFHTTPMessageRef request, CFHTTPAuthenticationRef auth, CFStringRef username, CFStringRef password, CFStreamError *error );

    Parameters

    request

    Request for which the authentication method is to be performed.

    auth

    A CFHTTPAuthentication object specifying the authentication method to perform.

    username

    Username for performing the authentication.

    password

    Password for performing the authentication.

    error

    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.

    Discussion

    This function performs the authentication method specified by auth on behalf of the request specified by request using the credentials specified by username and password. If, in addition to a username and password, you also need to specify an account domain, call CFHTTPMessageApplyCredentialDictionary instead of this function.

    This function is appropriate for performing several authentication requests. If you only need to make a single authentication request, consider using CFHTTPMessageAddAuthentication instead.

    Special Considerations

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

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

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

    Objective-C

    Boolean CFHTTPMessageApplyCredentialDictionary ( CFHTTPMessageRef request, CFHTTPAuthenticationRef auth, CFDictionaryRef dict, CFStreamError *error );

    Parameters

    request

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

    auth

    A CFHTTPAuthentication object specifying the authentication method to perform.

    dict

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

    error

    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.

    Discussion

    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.

    Availability

    Available in iOS 2.0 and later.

  • Adds authentication information to a request.

    Declaration

    Swift

    func CFHTTPMessageAddAuthentication(_ request: CFHTTPMessage, _ authenticationFailureResponse: CFHTTPMessage?, _ username: CFString, _ password: CFString, _ authenticationScheme: CFString?, _ forProxy: Bool) -> Bool

    Objective-C

    Boolean CFHTTPMessageAddAuthentication ( CFHTTPMessageRef request, CFHTTPMessageRef authenticationFailureResponse, CFStringRef username, CFStringRef password, CFStringRef authenticationScheme, Boolean forProxy );

    Parameters

    request

    The message to which to add authentication information.

    authenticationFailureResponse

    The response message that contains authentication failure information.

    username

    The username to add to the request.

    password

    The password to add to the request.

    authenticationScheme

    The authentication scheme to use (kCFHTTPAuthenticationSchemeBasic, kCFHTTPAuthenticationSchemeNegotiate, kCFHTTPAuthenticationSchemeNTLM, or kCFHTTPAuthenticationSchemeDigest), or pass NULL to use the strongest supported authentication scheme provided in the authenticationFailureResponse parameter.

    forProxy

    A flag indicating whether the authentication data that is being added is for a proxy’s use (TRUE) or for a remote server’s use (FALSE). If the error code provided by the authenticationFailureResponse parameter is 407, set forProxy to TRUE. If the error code is 401, set forProxy to FALSE.

    Return Value

    TRUE if the authentication information was successfully added, otherwise FALSE.

    Discussion

    This function adds the authentication information specified by the username, password, authenticationScheme, and forProxy parameters to the specified request message. The message referred to by the authenticationFailureResponse parameter typically contains a 401 or a 407 error code.

    This function is best suited for sending a single request to the server. If you need to send multiple requests, use CFHTTPMessageApplyCredentials.

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFHTTPMessageGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CFHTTPMessageGetTypeID ( void );

    Return Value

    The Core Foundation type identifier for the CFHTTPMessage opaque type.

    Availability

    Available in iOS 2.0 and later.

Data Types

  • An opaque reference representing an HTTP message.

    Declaration

    Swift

    class CFHTTPMessage { }

    Objective-C

    typedef struct __CFHTTPMessage *CFHTTPMessageRef;

    Availability

    Available in iOS 2.0 and later.

Constants

  • Sets the HTTP version in a CFHTTPMessage request or response object.

    Declaration

    Swift

    let kCFHTTPVersion1_0: CFString let kCFHTTPVersion1_1: CFString

    Objective-C

    const CFStringRef kCFHTTPVersion1_0; const CFStringRef kCFHTTPVersion1_1;

    Constants

    • kCFHTTPVersion1_0

      kCFHTTPVersion1_0

      Specifies HTTP version 1.0.

      Available in iOS 2.0 and later.

    • kCFHTTPVersion1_1

      kCFHTTPVersion1_1

      Specifies HTTP version 1.1.

      Available in iOS 2.0 and later.

    Discussion

    The HTTP version constants are used when you call CFHTTPMessageCreateRequest and CFHTTPMessageCreateResponse to create a request or response message.

  • Constants used to specify the desired authentication scheme for a request.

    Declaration

    Swift

    let kCFHTTPAuthenticationSchemeBasic: CFString let kCFHTTPAuthenticationSchemeDigest: CFString let kCFHTTPAuthenticationSchemeNTLM: CFString let kCFHTTPAuthenticationSchemeNegotiate: CFString let kCFHTTPAuthenticationSchemeKerberos: CFString let kCFHTTPAuthenticationSchemeNegotiate2: CFString let kCFHTTPAuthenticationSchemeOAuth1: CFString let kCFHTTPAuthenticationSchemeXMobileMeAuthToken: CFString

    Objective-C

    extern const CFStringRef kCFHTTPAuthenticationSchemeBasic; extern const CFStringRef kCFHTTPAuthenticationSchemeDigest; extern const CFStringRef kCFHTTPAuthenticationSchemeNTLM; extern const CFStringRef kCFHTTPAuthenticationSchemeNegotiate; extern const CFStringRef kCFHTTPAuthenticationSchemeKerberos; extern const CFStringRef kCFHTTPAuthenticationSchemeNegotiate2; extern const CFStringRef kCFHTTPAuthenticationSchemeOAuth1; extern const CFStringRef kCFHTTPAuthenticationSchemeXMobileMeAuthToken;

    Constants

    • kCFHTTPAuthenticationSchemeBasic

      kCFHTTPAuthenticationSchemeBasic

      Request the HTTP basic authentication scheme.

      Available in iOS 2.0 and later.

    • kCFHTTPAuthenticationSchemeDigest

      kCFHTTPAuthenticationSchemeDigest

      Request the HTTP digest authentication scheme.

      Available in iOS 2.0 and later.

    • kCFHTTPAuthenticationSchemeNTLM

      kCFHTTPAuthenticationSchemeNTLM

      Request the HTTP NTLM authentication scheme.

      Available in iOS 2.0 and later.

    • kCFHTTPAuthenticationSchemeNegotiate

      kCFHTTPAuthenticationSchemeNegotiate

      Request the HTTP Negotiate authentication scheme.

      Available in iOS 2.0 and later.

    • kCFHTTPAuthenticationSchemeKerberos

      kCFHTTPAuthenticationSchemeKerberos

      Request the HTTP Kerberos authentication scheme.

      Available in iOS 2.0 and later.

    • kCFHTTPAuthenticationSchemeNegotiate2

      kCFHTTPAuthenticationSchemeNegotiate2

      Request the HTTP Negotiate v2 authentication scheme.

      Available in iOS 3.0 and later.

    • kCFHTTPAuthenticationSchemeOAuth1

      kCFHTTPAuthenticationSchemeOAuth1

      Request the HTTP OAuth 1.0 authentication scheme.

      Available in iOS 7.0 and later.

    • kCFHTTPAuthenticationSchemeXMobileMeAuthToken

      kCFHTTPAuthenticationSchemeXMobileMeAuthToken

      Request the HTTP XMobileMeAuthToken authentication scheme.

      Available in iOS 4.3 and later.