Enums

The following enums are available globally.

  • Used to specify the way in which a set of parameters are applied to a URL request.

    • URL: Creates a query string to be set as or appended to any existing URL query for GET, HEAD, and DELETE requests, or set as the body for requests with any other HTTP method. The Content-Type HTTP header field of an encoded request with HTTP body is set to application/x-www-form-urlencoded; charset=utf-8. Since there is no published specification for how to encode collection types, the convention of appending [] to the key for array values (foo[]=1&foo[]=2), and appending the key surrounded by square brackets for nested dictionary values (foo[bar]=baz).

    • URLEncodedInURL: Creates query string to be set as or appended to any existing URL query. Uses the same implementation as the .URL case, but always applies the encoded result to the URL.

    • JSON: Uses NSJSONSerialization to create a JSON representation of the parameters object, which is set as the body of the request. The Content-Type HTTP header field of an encoded request is set to application/json.

    • PropertyList: Uses NSPropertyListSerialization to create a plist representation of the parameters object, according to the associated format and write options values, which is set as the body of the request. The Content-Type HTTP header field of an encoded request is set to application/x-plist.

    • Custom: Uses the associated closure value to construct a new request given an existing request and parameters.

    See more

    Declaration

    Swift

    public enum ParameterEncoding
  • Used to represent whether a request was successful or encountered an error.

    • Success: The request and all post processing operations were successful resulting in the serialization of the provided associated value.
    • Failure: The request encountered an error resulting in a failure. The associated values are the original data provided by the server as well as the error that caused the failure.
    See more

    Declaration

    Swift

    public enum Result<Value, Error: ErrorType>
  • The ServerTrustPolicy evaluates the server trust generally provided by an NSURLAuthenticationChallenge when connecting to a server over a secure HTTPS connection. The policy configuration then evaluates the server trust with a given set of criteria to determine whether the server trust is valid and the connection should be made.

    Using pinned certificates or public keys for evaluation helps prevent man-in-the-middle (MITM) attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with pinning enabled.

    • PerformDefaultEvaluation: Uses the default server trust evaluation while allowing you to control whether to validate the host provided by the challenge. Applications are encouraged to always validate the host in production environments to guarantee the validity of the server’s certificate chain.

    • PinCertificates: Uses the pinned certificates to validate the server trust. The server trust is considered valid if one of the pinned certificates match one of the server certificates. By validating both the certificate chain and host, certificate pinning provides a very secure form of server trust validation mitigating most, if not all, MITM attacks. Applications are encouraged to always validate the host and require a valid certificate chain in production environments.

    • PinPublicKeys: Uses the pinned public keys to validate the server trust. The server trust is considered valid if one of the pinned public keys match one of the server certificate public keys. By validating both the certificate chain and host, public key pinning provides a very secure form of server trust validation mitigating most, if not all, MITM attacks. Applications are encouraged to always validate the host and require a valid certificate chain in production environments.

    • DisableEvaluation: Disables all evaluation which in turn will always consider any server trust as valid.

    • CustomEvaluation: Uses the associated closure to evaluate the validity of the server trust.

    See more

    Declaration

    Swift

    public enum ServerTrustPolicy