Header
public struct Header : Hashable
A header in a HTTP request. A header consists of a series of fields containing a key and a value. Keys are
represented by the Field.Name
type while values are simply String
s.
Note
AHeader
instance does not preserve the order of fields added to it.
-
A dictionary representation of the header.
Declaration
Swift
public var dictionaryValue: [String : String] { get }
-
true
if the header is empty.Declaration
Swift
public var isEmpty: Bool { get }
-
Initializes a new
Header
containing the provided fields.Declaration
Swift
public init(_ fields: [Field])
Parameters
fields
The fields to initialize the header with.
-
An empty header.
Declaration
Swift
public static var empty: Header { get }
-
Adds
field
into the header. If a field with the same name already exists, its value is joined withfield
‘s value using a,
.Declaration
Swift
public mutating func add(_ field: Field)
-
Sets
field
in the header, replacing any existing values.Declaration
Swift
public mutating func set(_ field: Field)
-
Returns
true
if the header contains a value for the field namedfield
.Declaration
Swift
public func contains(_ name: Field.Name) -> Bool
-
Accesses the value of the header field matching
name
.Declaration
Swift
public subscript(name: Field.Name) -> String? { get set }
-
Undocumented
Declaration
Swift
public init(_ fields: Field...)
-
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public init(arrayLiteral elements: Field...)