The NSHTTPURLResponse class is a subclass of URLResponse that provides methods for accessing information specific to HTTP protocol responses. Whenever you make HTTP URL load requests, any response objects you get back from the URLSession, NSURLConnection, or NSURLDownload class are instances of the NSHTTPURLResponse class.


Initializing a Response Object

init?(url: URL, statusCode: Int, httpVersion: String?, headerFields: [String : String]?)

Initializes an HTTP URL response object with a status code, protocol version, and response headers.

Getting HTTP Response Headers

var allHeaderFields: [AnyHashable : Any]

All HTTP header fields of the receiver.

Getting Response Status Code

class func localizedString(forStatusCode: Int)

Returns a localized string corresponding to a specified HTTP status code.

var statusCode: Int

The receiver’s HTTP status code.


Inherits From