HttpHeader
public struct HttpHeader
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
.
-
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
See moreString
. Nonetheless, the usage of static variables is encouraged to prevent needless typos.Declaration
Swift
public struct Field
-
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.
-
Declaration
Swift
public init(dictionaryLiteral elements: (Field, String)...)