Response

public protocol Response

Represents an HTTP response.

  • The original request that produced this response.

    Declaration

    Swift

    var data: Data { get }
  • body() Asynchronous

    Returns the body of the response.

    Declaration

    Swift

    func body() async -> String

    Return Value

    The body as a String.

  • Returns the HTTP status code.

    Declaration

    Swift

    func status() -> Int

    Return Value

    The status code as an Int.

  • Returns the cookies included in the response.

    Declaration

    Swift

    func getCookies() -> [HTTPCookie]

    Return Value

    A Cookies container.

  • Returns the value of a header.

    Declaration

    Swift

    func header(name: String) -> String?

    Parameters

    name

    The name of the header.

    Return Value

    The header value, or nil if not present.

  • json() Default implementation

    Returns the body of the response as a JSON object.

    Default Implementation

    Returns the body of the response as a JSON object.

    Declaration

    Swift

    func json() throws -> [String : Any]

    Return Value

    The body of the response as a JSON object.