HTTPHeaders - SwiftDocOrg/Alamofire GitHub Wiki
HTTPHeaders
An order-preserving and case-insensitive representation of HTTP headers.
public struct HTTPHeaders
Inheritance
Collection, CustomStringConvertible, ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral, Sequence
Initializers
init()
Creates an empty instance.
public init()
init(_:β)
Creates an instance from an array of HTTPHeaders. Duplicate case-insensitive names are collapsed into the last
name and value encountered.
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.
public init(_ dictionary:β [String:β String])
init(dictionaryLiteral:β)
public init(dictionaryLiteral elements:β (String, String))
init(arrayLiteral:β)
public init(arrayLiteral elements:β HTTPHeader)
Properties
dictionary
The dictionary representation of all headers.
var dictionary:β [String:β String]
This representation does not preserve the current order of the instance.
startIndex
var startIndex:β Int
endIndex
var endIndex:β Int
description
var description:β String
`default`
The default set of HTTPHeaders used by Alamofire. Includes Accept-Encoding, Accept-Language, and
User-Agent.
let `default`:β HTTPHeaders = [.defaultAcceptEncoding,
.defaultAcceptLanguage,
.defaultUserAgent]
Methods
add(name:βvalue:β)
Case-insensitively updates or appends an HTTPHeader into the instance using the provided name and value.
public mutating func add(name:β String, value:β String)
Parameters
- name:β The
HTTPHeadername. - value:β The `HTTPHeader value.
add(_:β)
Case-insensitively updates or appends the provided HTTPHeader into the instance.
public mutating func add(_ header:β HTTPHeader)
Parameters
- header:β The
HTTPHeaderto update or append.
update(name:βvalue:β)
Case-insensitively updates or appends an HTTPHeader into the instance using the provided name and value.
public mutating func update(name:β String, value:β String)
Parameters
- name:β The
HTTPHeadername. - value:β The `HTTPHeader value.
update(_:β)
Case-insensitively updates or appends the provided HTTPHeader into the instance.
public mutating func update(_ header:β HTTPHeader)
Parameters
- header:β The
HTTPHeaderto update or append.
remove(name:β)
Case-insensitively removes an HTTPHeader, if it exists, from the instance.
public mutating func remove(name:β String)
Parameters
- name:β The name of the
HTTPHeaderto remove.
sort()
Sort the current instance by header name.
public mutating func sort()
sorted()
Returns an instance sorted by header name.
public func sorted() -> HTTPHeaders
Returns
A copy of the current instance sorted by name.
value(for:β)
Case-insensitively find a header's value by name.
public func value(for name:β String) -> String?
Parameters
- name:β The name of the header to search for, case-insensitively.
Returns
The value of header, if it exists.
makeIterator()
public func makeIterator() -> IndexingIterator<[HTTPHeader]>
index(after:β)
public func index(after i:β Int) -> Int