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 Strings.

Note

A Header 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 with field‘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)
  • Removes the field named name from the header, returning the field if it was present.

    Declaration

    Swift

    @discardableResult
    public mutating func remove(_ name: Field.Name) -> Field?
  • Returns true if the header contains a value for the field named field.

    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 }