<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/HTTPURLResponse",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSHTTPURLResponse"
  },
  "title" : "HTTPURLResponse"
}
-->

# HTTPURLResponse

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

```
class HTTPURLResponse
```

## Overview

The [`HTTPURLResponse`](/documentation/Foundation/HTTPURLResponse) class is a subclass of [`URLResponse`](/documentation/Foundation/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`](/documentation/Foundation/URLSession), [`NSURLConnection`](/documentation/Foundation/NSURLConnection), or [`NSURLDownload`](/documentation/Foundation/NSURLDownload) class are instances of the [`HTTPURLResponse`](/documentation/Foundation/HTTPURLResponse) class.

## Topics

### Initializing a response object

[`init(url:statusCode:httpVersion:headerFields:)`](/documentation/Foundation/HTTPURLResponse/init(url:statusCode:httpVersion:headerFields:))

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

### Getting HTTP response headers

[`allHeaderFields`](/documentation/Foundation/HTTPURLResponse/allHeaderFields)

All HTTP header fields of the response.

[`value(forHTTPHeaderField:)`](/documentation/Foundation/HTTPURLResponse/value(forHTTPHeaderField:))

Returns the value that corresponds to the given header field.

### Getting response status codes

[`localizedString(forStatusCode:)`](/documentation/Foundation/HTTPURLResponse/localizedString(forStatusCode:))

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

[`statusCode`](/documentation/Foundation/HTTPURLResponse/statusCode)

The response’s HTTP status code.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)
