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


class URLResponse : NSObject


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?)

Creates an initialized URLResponse 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 HTTPURLResponse

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