HTTPHeadersPatch

public struct HTTPHeadersPatch : ExpressibleByDictionaryLiteral

Used to Patch HTTPHeaders. Remembers if a header was added in with add or replaceOrAdd

  • Construct a HTTPHeaders structure.

    Declaration

    Swift

    public init(dictionaryLiteral elements: (String, String)...)
  • Add a header name/value pair to the block.

    This method is strictly additive: if there are other values for the given header name already in the block, this will add a new entry.

    Declaration

    Swift

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

    Parameters

    name

    The header field name. For maximum compatibility this should be an ASCII string. For future-proofing with HTTP/2 lowercase header names are strongly recommended.

    value

    The header field value to add for the given name.

  • Add a sequence of header name/value pairs to the block.

    This method is strictly additive: if there are other entries with the same header name already in the block, this will add new entries.

    Declaration

    Swift

    @inlinable
    public mutating func add<S>(contentsOf other: S) where S : Sequence, S.Element == (String, String)

    Parameters

    contentsOf

    The sequence of header name/value pairs. For maximum compatibility the header should be an ASCII string. For future-proofing with HTTP/2 lowercase header names are strongly recommended.

  • Declaration

    Swift

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

    Parameters

    value

    The header field value to add for the given name.

  • Remove all values for a given header name from the block.

    This method uses case-insensitive comparisons for the header field name.

    Declaration

    Swift

    public mutating func remove(name nameToRemove: String)

    Parameters

    name

    The name of the header field to remove from the block.