Field

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

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.

Header Fields

  • HTTP “Accept” header: defines a list of allowed media types in the response.

    Declaration

    Swift

    public static let accept: HttpHeader.Field
  • HTTP “Accept-Language” header: defines a list of allowed languages in the response.

    Declaration

    Swift

    public static let acceptLanguage: HttpHeader.Field
  • HTTP “Authorization” header: authentication credentials for HTTP authentication.

    Declaration

    Swift

    public static let authorization: HttpHeader.Field
  • HTTP “Content-Length” header: the length of the request body in bytes.

    Declaration

    Swift

    public static let contentLength: HttpHeader.Field
  • HTTP “Content-Type” header: the MIME type of the request body. Use HttpMimeType for defining values.

    Declaration

    Swift

    public static let contentType: HttpHeader.Field
  • Custom HTTP “X-Api-Key” header that is used often: sets an API key that identifies the application to the server.

    Declaration

    Swift

    public static let apiKey: HttpHeader.Field

Protocol Conformances