HTTPCookies

open class HTTPCookies : ObjectBase

Encapsulates a map of HTTP cookies.

  • An immutable empty map of HTTP cookies.

    Declaration

    Swift

    public static let empty: HTTPCookies
  • Default initializer.

    Declaration

    Swift

    override public init()
  • Add all of the cookies from another cookies object into this cookies object.

    Declaration

    Swift

    open func addAll(other: HTTPCookies)

    Parameters

    other

    Another cookies object.

  • Declaration

    Swift

    open func concurrent() -> HTTPCookies

    Return Value

    a thread-safe cookies object that delegates to this cookies object. A regular HttpCookies object is not thread-safe for concurrent read/write access. This function will return a thread-safe wrapper.

  • Declaration

    Swift

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

    Parameters

    name

    Cookie name.

    Return Value

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

  • Declaration

    Swift

    open func copy() -> HTTPCookies

    Return Value

    A copy of these cookies.

  • Declaration

    Swift

    open func entries() -> StringMap.EntryList

    Return Value

    The cookie entries (name/value pairs).

  • Declaration

    Swift

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

    Parameters

    name

    Cookie name.

    Return Value

    true if a specified cookie exists.

  • Declaration

    Swift

    open func keys() -> StringList

    Return Value

    The cookie names.

  • Clear all the cookies.

    Declaration

    Swift

    open func removeAll()
  • Delete the value of a cookie, if present.

    Declaration

    Swift

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

    Parameters

    name

    Cookie name.

    Return Value

    true if a cookie was deleted.

  • Set the value of a cookie.

    Declaration

    Swift

    open func setCookie(withName name: String, value: String)

    Parameters

    name

    Cookie name.

    value

    Cookie value.

  • The number of cookies.

    Declaration

    Swift

    open var size: Int { get }
  • Declaration

    Swift

    open func sortedEntries() -> StringMap.EntryList

    Return Value

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

  • Declaration

    Swift

    open func sortedKeys() -> StringList

    Return Value

    The cookie names in sorted order.

  • Declaration

    Swift

    override open func toString() -> String

    Return Value

    Cookies as a JSON string.