<!--
{
  "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

[`-  initWithURL:statusCode:HTTPVersion:headerFields:`](/documentation/Foundation/HTTPURLResponse/init(url:statusCode:httpVersion:headerFields:)-21j4x)

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.

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

Returns the value that corresponds to the given header field.

### Getting response status codes

[`+  localizedStringForStatusCode:`](/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.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

### Inherits From

[`URLResponse`](/documentation/Foundation/URLResponse)

---

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)