Response

public class Response

Contains useful response data from an HTTP request made by the Request class.

  • The HTTP status of the response.

    Declaration

    Swift

    public let statusCode: Int?
  • HTTP headers from the response.

    Declaration

    Swift

    public let headers: [AnyHashable: Any]?
  • The body of the response. Returns nil if there is no body or the body cannot be converted to a String.

    Declaration

    Swift

    public let responseText: String?
  • The body of the response. Returns nil if there is no body or if the response is not valid Data.

    Declaration

    Swift

    public let responseData: Data?
  • The response is considered successful if the returned status code is in the 2xx range.

    Declaration

    Swift

    public let isSuccessful: Bool
  • Converts an HTTPURLResponse to a more accessible response object.

    Declaration

    Swift

    public init(responseData: Data?, httpResponse: HTTPURLResponse?, isRedirect: Bool)

    Parameters

    responseData

    Data returned from the server.

    httpResponse

    Response object returned from the URLSession request.

    isRedirect

    True if the response requires a redirect.