The metadata associated with the response to a URL load request, independent of protocol and URL scheme.


The related HTTPURLResponse class is a commonly used subclass of URLResponse 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 URLResponse object you get back is actually an instance of the HTTPURLResponse class.


Creating a response

init(url: URL, mimeType: String?, expectedContentLength: Int, textEncodingName: String?)

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

Getting the response properties

var expectedContentLength: Int64

The expected length of the response’s content.

var suggestedFilename: String?

A suggested filename for the response data.

var mimeType: String?

The MIME type of the response.

var textEncodingName: String?

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

var url: URL?

The URL for the response.


Inherits From

See Also

Requests and Responses

struct URLRequest

A URL load request that is independent of protocol or URL scheme.

class NSMutableURLRequest

A mutable object that represents a URL load request that bridges to URLRequest; use NSMutableURLRequest when you need reference semantics or other Foundation-specific behavior.

class HTTPURLResponse

The metadata associated with the response to an HTTP protocol URL load request.