HTTPHeaders
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.
-
Creates an empty instance.
Declaration
Swift
public init() -
Creates an instance from an array of
HTTPHeaders. Duplicate case-insensitive names are collapsed into the last name and value encountered.Declaration
Swift
public init(_ headers: [HTTPHeader]) -
Creates an instance from a
[String: String]. Duplicate case-insensitive names are collapsed into the last name and value encountered.Declaration
Swift
public init(_ dictionary: [String : String]) -
Case-insensitively updates or appends an
HTTPHeaderinto the instance using the providednameandvalue.Declaration
Swift
public mutating func add(name: String, value: String)Parameters
nameThe
HTTPHeadername.valueThe
HTTPHeadervalue. -
Case-insensitively updates or appends the provided
HTTPHeaderinto the instance.Declaration
Swift
public mutating func add(_ header: HTTPHeader)Parameters
headerThe
HTTPHeaderto update or append. -
Case-insensitively updates or appends an
HTTPHeaderinto the instance using the providednameandvalue.Declaration
Swift
public mutating func update(name: String, value: String)Parameters
nameThe
HTTPHeadername.valueThe
HTTPHeadervalue. -
Case-insensitively updates or appends the provided
HTTPHeaderinto the instance.Declaration
Swift
public mutating func update(_ header: HTTPHeader)Parameters
headerThe
HTTPHeaderto update or append. -
Case-insensitively removes an
HTTPHeader, if it exists, from the instance.Declaration
Swift
public mutating func remove(name: String)Parameters
nameThe name of the
HTTPHeaderto remove. -
Sort the current instance by header name, case insensitively.
Declaration
Swift
public mutating func sort() -
Returns an instance sorted by header name.
Declaration
Swift
public func sorted() -> HTTPHeadersReturn Value
A copy of the current instance sorted by name.
-
Case-insensitively find a header’s value by name.
Declaration
Swift
public func value(for name: String) -> String?Parameters
nameThe name of the header to search for, case-insensitively.
Return Value
The value of header, if it exists.
-
Case-insensitively access the header with the given name.
Declaration
Swift
public subscript(name: String) -> String? { get set }Parameters
nameThe name of the header.
-
The dictionary representation of all headers.
This representation does not preserve the current order of the instance.
Declaration
Swift
public var dictionary: [String : String] { get } -
Declaration
Swift
public init(dictionaryLiteral elements: (String, String)...) -
Declaration
Swift
public init(arrayLiteral elements: HTTPHeader...) -
Declaration
Swift
public func makeIterator() -> IndexingIterator<[HTTPHeader]> -
Declaration
Swift
public var startIndex: Int { get } -
Declaration
Swift
public var endIndex: Int { get } -
Declaration
Swift
public subscript(position: Int) -> HTTPHeader { get } -
Declaration
Swift
public func index(after i: Int) -> Int -
Declaration
Swift
public var description: String { get }
-
The default set of
HTTPHeadersused by Alamofire. IncludesAccept-Encoding,Accept-Language, andUser-Agent.Declaration
Swift
public static let `default`: HTTPHeaders
View on GitHub
Install in Dash