Back to Alamofire

HTTPHeaders

docs/docsets/Alamofire.docset/Contents/Resources/Documents/Structs/HTTPHeaders.html

5.12.05.9 KB
Original Source

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.

`

                init()
                `

Creates an empty instance.

Declaration

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.

Declaration

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.

Declaration

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.

Declaration

Swift

public mutating func add(name: String, value: String)

Parameters

| name |

The HTTPHeader name.

| | value |

The HTTPHeader value.

|

`

                add(_:)
                `

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.

|

`

                update(name:value:)
                `

Case-insensitively updates or appends an HTTPHeader into the instance using the provided name and value.

Declaration

Swift

public mutating func update(name: String, value: String)

Parameters

| name |

The HTTPHeader name.

| | value |

The HTTPHeader value.

|

`

                update(_:)
                `

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.

|

`

                remove(name:)
                `

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()
                `

Sort the current instance by header name, case insensitively.

Declaration

Swift

public mutating func sort()

`

                sorted()
                `

Returns an instance sorted by header name.

Declaration

Swift

public func sorted() -> HTTPHeaders

Return Value

A copy of the current instance sorted by name.

`

                value(for:)
                `

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.

`

                subscript(_:)
                `

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.

|

`

                dictionary
                `

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 }

`

                init(dictionaryLiteral:)
                `

Declaration

Swift

public init(dictionaryLiteral elements: (String, String)...)

`

                init(arrayLiteral:)
                `

Declaration

Swift

public init(arrayLiteral elements: HTTPHeader...)

`

                makeIterator()
                `

Declaration

Swift

public func makeIterator() -> IndexingIterator<[HTTPHeader]>

`

                startIndex
                `

Declaration

Swift

public var startIndex: Int { get }

`

                endIndex
                `

Declaration

Swift

public var endIndex: Int { get }

`

                subscript(_:)
                `

Declaration

Swift

public subscript(position: Int) -> HTTPHeader { get }

`

                index(after:)
                `

Declaration

Swift

public func index(after i: Int) -> Int

`

                description
                `

Declaration

Swift

public var description: String { get }

Defaults

`

                default
                `

The default set of HTTPHeaders used by Alamofire. Includes Accept-Encoding, Accept-Language, and User-Agent.

Declaration

Swift

public static let `default`: HTTPHeaders