Request

public struct Request

Represent HTTP request.

  • Request HTTP method, defaults to GET.

    Declaration

    Swift

    public let method: HTTPMethod
  • url

    Remote URL.

    Declaration

    Swift

    public let url: URL
  • Remote HTTP scheme, resolved from URL.

    Declaration

    Swift

    public let scheme: String
  • Remote host, resolved from URL.

    Declaration

    Swift

    public let host: String
  • Request custom HTTP Headers, defaults to no headers.

    Declaration

    Swift

    public var headers: HTTPHeaders
  • Request body, defaults to no body.

    Declaration

    Swift

    public var body: Body?
  • Create HTTP request.

    Throws

    • invalidURL if URL cannot be parsed.
    • emptyScheme if URL does not contain HTTP scheme.
    • unsupportedScheme if URL does contains unsupported HTTP scheme.
    • emptyHost if URL does not contains a host.

    Declaration

    Swift

    public init(url: String, method: HTTPMethod = .GET, headers: HTTPHeaders = HTTPHeaders(), body: Body? = nil) throws

    Parameters

    url

    Remote URL.

    version

    HTTP version.

    method

    HTTP method.

    headers

    Custom HTTP headers.

    body

    Request body.

  • Create an HTTP Request.

    Throws

    • emptyScheme if URL does not contain HTTP scheme.
    • unsupportedScheme if URL does contains unsupported HTTP scheme.
    • emptyHost if URL does not contains a host.
    • missingSocketPath if URL does not contains a socketPath as an encoded host.

    Declaration

    Swift

    public init(url: URL, method: HTTPMethod = .GET, headers: HTTPHeaders = HTTPHeaders(), body: Body? = nil) throws

    Parameters

    url

    Remote URL.

    method

    HTTP method.

    headers

    Custom HTTP headers.

    body

    Request body.

  • Whether request will be executed using secure socket.

    Declaration

    Swift

    public var useTLS: Bool { get }
  • Resolved port.

    Declaration

    Swift

    public var port: Int { get }