docs/docsets/Alamofire.docset/Contents/Resources/Documents/Structs/HTTPHeaders.html
public struct HTTPHeaders : Equatable, Hashable, Sendable
extension HTTPHeaders: ExpressibleByDictionaryLiteral
extension HTTPHeaders: ExpressibleByArrayLiteral
extension HTTPHeaders: Sequence
extension HTTPHeaders: Collection
extension HTTPHeaders: CustomStringConvertible
An order-preserving and case-insensitive representation of HTTP headers.
`
init()
`
Creates an empty instance.
Swift
public init()
`
init(_:)
`
Creates an instance from an array of HTTPHeaders. Duplicate case-insensitive names are collapsed into the last name and value encountered.
Swift
public init(_ headers: [HTTPHeader])
`
init(_:)
`
Creates an instance from a [String: String]. Duplicate case-insensitive names are collapsed into the last name and value encountered.
Swift
public init(_ dictionary: [String : String])
`
add(name:value:)
`
Case-insensitively updates or appends an HTTPHeader into the instance using the provided name and value.
Swift
public mutating func add(name: String, value: String)
| name |
The HTTPHeader name.
|
| value |
The HTTPHeader value.
|
`
add(_:)
`
Case-insensitively updates or appends the provided HTTPHeader into the instance.
Swift
public mutating func add(_ header: HTTPHeader)
| header |
The HTTPHeader to update or append.
|
`
update(name:value:)
`
Case-insensitively updates or appends an HTTPHeader into the instance using the provided name and value.
Swift
public mutating func update(name: String, value: String)
| name |
The HTTPHeader name.
|
| value |
The HTTPHeader value.
|
`
update(_:)
`
Case-insensitively updates or appends the provided HTTPHeader into the instance.
Swift
public mutating func update(_ header: HTTPHeader)
| header |
The HTTPHeader to update or append.
|
`
remove(name:)
`
Case-insensitively removes an HTTPHeader, if it exists, from the instance.
Swift
public mutating func remove(name: String)
| name |
The name of the HTTPHeader to remove.
|
`
sort()
`
Sort the current instance by header name, case insensitively.
Swift
public mutating func sort()
`
sorted()
`
Returns an instance sorted by header name.
Swift
public func sorted() -> HTTPHeaders
A copy of the current instance sorted by name.
`
value(for:)
`
Case-insensitively find a header’s value by name.
Swift
public func value(for name: String) -> String?
| name |
The name of the header to search for, case-insensitively.
|
The value of header, if it exists.
`
subscript(_:)
`
Case-insensitively access the header with the given name.
Swift
public subscript(name: String) -> String? { get set }
| name |
The name of the header.
|
`
dictionary
`
The dictionary representation of all headers.
This representation does not preserve the current order of the instance.
Swift
public var dictionary: [String : String] { get }
`
init(dictionaryLiteral:)
`
Swift
public init(dictionaryLiteral elements: (String, String)...)
`
init(arrayLiteral:)
`
Swift
public init(arrayLiteral elements: HTTPHeader...)
`
makeIterator()
`
Swift
public func makeIterator() -> IndexingIterator<[HTTPHeader]>
`
startIndex
`
Swift
public var startIndex: Int { get }
`
endIndex
`
Swift
public var endIndex: Int { get }
`
subscript(_:)
`
Swift
public subscript(position: Int) -> HTTPHeader { get }
`
index(after:)
`
Swift
public func index(after i: Int) -> Int
`
description
`
Swift
public var description: String { get }
`
default
`
The default set of HTTPHeaders used by Alamofire. Includes Accept-Encoding, Accept-Language, and User-Agent.
Swift
public static let `default`: HTTPHeaders