Initializer

init(url:statusCode:httpVersion:headerFields:)

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

Declaration

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

Parameters

url

The URL from which the response was generated.

statusCode

The HTTP status code to return (404, for example). See RFC 2616 for details.

HTTPVersion

The version of the HTTP response as returned by the server. This is typically represented as "HTTP/1.1".

headerFields

A dictionary representing the keys and values from the server’s response header.

Return Value

An initialized HTTPURLResponse object or nil if an error occurred during initialization.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software