<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURLRequest/value(forHTTPHeaderField:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLRequest(im)valueForHTTPHeaderField:"
  },
  "title" : "value(forHTTPHeaderField:)"
}
-->

# value(forHTTPHeaderField:)

Returns the value of the specified HTTP header field.

```
func value(forHTTPHeaderField field: String) -> String?
```

## Parameters

`field`

The name of the header field whose value is to be returned. In keeping with the HTTP RFC, HTTP header field names are case-insensitive.

## Return Value

The value associated with the header field `field`, or `nil` if there is no corresponding header field.

## See Also

[`-  addValue:forHTTPHeaderField:`](/documentation/Foundation/NSMutableURLRequest/addValue(_:forHTTPHeaderField:))

Adds a value to the header field.

[`-  setValue:forHTTPHeaderField:`](/documentation/Foundation/NSMutableURLRequest/setValue(_:forHTTPHeaderField:))

Sets a value for the header field.



---

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)