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
HTTPHeader
s. 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
HTTPHeader
into the instance using the providedname
andvalue
.Declaration
Swift
public mutating func add(name: String, value: String)
Parameters
name
The
HTTPHeader
name.value
The
HTTPHeader
value. -
Case-insensitively updates or appends the provided
HTTPHeader
into the instance.Declaration
Swift
public mutating func add(_ header: HTTPHeader)
Parameters
header
The
HTTPHeader
to update or append. -
Case-insensitively updates or appends an
HTTPHeader
into the instance using the providedname
andvalue
.Declaration
Swift
public mutating func update(name: String, value: String)
Parameters
name
The
HTTPHeader
name.value
The
HTTPHeader
value. -
Case-insensitively updates or appends the provided
HTTPHeader
into the instance.Declaration
Swift
public mutating func update(_ header: HTTPHeader)
Parameters
header
The
HTTPHeader
to update or append. -
Case-insensitively removes an
HTTPHeader
, if it exists, from the instance.Declaration
Swift
public mutating func remove(name: String)
Parameters
name
The name of the
HTTPHeader
to 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() -> HTTPHeaders
Return 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
name
The 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
name
The 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
HTTPHeaders
used by Alamofire. IncludesAccept-Encoding
,Accept-Language
, andUser-Agent
.Declaration
Swift
public static let `default`: HTTPHeaders