Options

public enum Options

Client request options enum. This allows the client to specify certain parameteres such as HTTP headers, HTTP methods, host names, and SSL credentials.

Usage Example:

//If present in the options provided, the client will try to use HTTP/2 protocol for the connection.
Options.useHTTP2
  • Specifies the HTTP method (i.e. PUT, POST…) to be sent in the request

    Declaration

    Swift

    case method(String)
  • Specifies the schema (i.e. HTTP, HTTPS) to be used in the URL of request

    Declaration

    Swift

    case schema(String)
  • Specifies the host name to be used in the URL of request

    Declaration

    Swift

    case hostname(String)
  • Specifies the port to be used in the URL of request.

    Note that an Int16 is incapable of representing all possible port values, however it forms part of the Kitura-net 2.0 API. In order to pass a port number greater than 32,767 (Int16.max), use the following code:

    let portNumber: UInt16 = 65535
    let portOption: ClientRequest.Options = .port(Int16(bitPattern: portNumber))
    

    Declaration

    Swift

    case port(Int16)
  • Specifies the path to be used in the URL of request

    Declaration

    Swift

    case path(String)
  • Specifies the HTTP headers to be sent with the request

    Declaration

    Swift

    case headers([String : String])
  • Specifies the user name to be sent with the request, when using basic auth authentication

    Declaration

    Swift

    case username(String)
  • Specifies the password to be sent with the request, when using basic auth authentication

    Declaration

    Swift

    case password(String)
  • Specifies the maximum number of redirect responses that will be followed (i.e. re-issue the request to the location received in the redirect response)

    Declaration

    Swift

    case maxRedirects(Int)
  • If present, the SSL credentials of the remote server will not be verified.

    Note

    This is very useful when working with self signed certificates.

    Declaration

    Swift

    case disableSSLVerification
  • If present, the client will try to use HTTP/2 protocol for the connection.

    Declaration

    Swift

    case useHTTP2