<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLRequest/addValue(_:forHTTPHeaderField:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation10URLRequestV8addValue_18forHTTPHeaderFieldySS_SStF"
  },
  "title" : "addValue(_:forHTTPHeaderField:)"
}
-->

# addValue(_:forHTTPHeaderField:)

Adds a value to the header field.

```
mutating func addValue(_ value: String, forHTTPHeaderField field: String)
```

## Parameters

`value`

The value for the header field.

`field`

The name of the header field. In keeping with the HTTP RFC, HTTP header field names are case insensitive.

## Discussion

This method provides the ability to add values to header fields incrementally. If a value was previously set for the specified field, the supplied value is appended to the existing value using the appropriate field delimiter (a comma).

Certain header fields are reserved (see [`Reserved HTTP headers`](/documentation/Foundation/NSURLRequest#Reserved-HTTP-headers)). Do not use this method to change such headers.

---

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)