HTTPHeaders

open class HTTPHeaders: ObjectBase

Encapsulates a map of HTTP headers, allowing case-insensitive lookup.

  • An immutable empty map of HTTP headers.

    Declaration

    Swift

    public static let empty: HTTPHeaders = HTTPHeaders._new1_in_HTTPHeaders(StringMap.empty, StringMap.empty)
  • Default initializer.

    Declaration

    Swift

    override public init()
  • Declaration

    Swift

    open func concurrent() -> HTTPHeaders

    Return Value

    a thread-safe headers object that delegates to self headers object. An HttpHeaders object is not thread-safe for concurrent read/write access. This function will return a thread-safe wrapper.

  • Declaration

    Swift

    open func copy() -> HTTPHeaders

    Return Value

    A copy of these headers.

  • Declaration

    Swift

    open func entries() -> StringMap.EntryList

    Return Value

    The header entries (name/value pairs).

  • Declaration

    Swift

    open func hasHeader(withName name: String) -> Bool

    Parameters

    name

    Header name.

    Return Value

    true if a specified header exists.

  • Declaration

    Swift

    open func header(withName name: String) -> String?

    Parameters

    name

    Header name.

    Return Value

    The value of a header, or nil if not found.

  • Declaration

    Swift

    open func keys() -> StringList

    Return Value

    The header names.

  • Clear all the headers.

    Declaration

    Swift

    open func removeAll() -> Void
  • Delete the value of a header, if present.

    Declaration

    Swift

    open func removeHeader(withName name: String) -> Bool

    Parameters

    name

    Header name.

    Return Value

    true if a cookie was deleted.

  • Set the value of a header.

    Declaration

    Swift

    open func setHeader(withName name: String, value: String) -> Void

    Parameters

    name

    Header name.

    value

    Header value.

  • The number of headers.

    Declaration

    Swift

    open var size: Int
  • Declaration

    Swift

    open func sortedEntries() -> StringMap.EntryList

    Return Value

    The header entries (name/value pairs) sorted by name (case insensitive).

  • Declaration

    Swift

    override open func toString() -> String

    Return Value

    Headers as a JSON string.