The NSURLResponse class encapsulates the metadata associated with the response to a a URL load request in a manner independent of protocol and URL scheme.


The related HTTPURLResponse class is a commonly used subclass of NSURLResponse whose objects represent a response to an HTTP URL load request and store additional protocol-specific information such as the response headers. Whenever you make an HTTP request, the NSURLResponse object you get back is actually an instance of the HTTPURLResponse class.


Creating a response

init(url:​ URL, mime​Type:​ String?, expected​Content​Length:​ Int, text​Encoding​Name:​ String?)

Returns an initialized NSURLResponse object with the URL, MIME type, length, and text encoding set to given values.

Getting the response properties

var expected​Content​Length:​ Int64

The expected length of the response’s content.

var suggested​Filename:​ String?

A suggested filename for the response data.

var mime​Type:​ String?

The MIME type of the response.

var text​Encoding​Name:​ String?

The name of the text encoding provided by the response’s originating source.

var url:​ URL?

The URL for the response.