HttpHeader

public struct HttpHeader
extension HttpHeader: Equatable
extension HttpHeader: Hashable
extension HttpHeader: ExpressibleByDictionaryLiteral

This struct is used to represent a header of HTTP requests. It can contain arbitrarily many fields which are each defined by a key and a value. The key is of the type HttpHeader.Field. The value always needs to be of type String.

Inner Type

  • A header field represents the key for a specific entry in the HTTP header. There exist some pre-defined header fields that are used frequently (e.g. Content-Type) which are exposed via static variables. The user may add additional static variables here to provide a safe way for using header fields. Header fields can also be (transparently) initialized via strings, i.e. anywhere where a header field is required, the user may simply pass a String. Nonetheless, the usage of static variables is encouraged to prevent needless typos.

    See more

    Declaration

    Swift

    public struct Field
    extension HttpHeader.Field: ExpressibleByStringLiteral
    extension HttpHeader.Field: Equatable
    extension HttpHeader.Field: Hashable

Initialization

  • Initializes a new header for a HTTP request with the given fields.

    Declaration

    Swift

    public init(_ fields: [Field : String])

    Parameters

    fields

    A mapping from header fields (more precisely, keys) to values.

Protocol Conformances

  • Declaration

    Swift

    public static func == (lhs: HttpHeader, rhs: HttpHeader) -> Bool
  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)
  • Declaration

    Swift

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

Operators

  • Combines the fields of two different headers into a single header containing all fields. Whenever a field occurs in both headers, the value of the second header is used.

    Declaration

    Swift

    public static func + (lhs: `Self`, rhs: `Self`) -> HttpHeader