Package java.net

Class CookieHandler

  • Direct Known Subclasses:
    CookieManager

    public abstract class CookieHandler
    extends Object
    This class provides a way to manage cookies with a HTTP protocol handler.
    • Constructor Detail

      • CookieHandler

        public CookieHandler()
    • Method Detail

      • getDefault

        public static CookieHandler getDefault()
        Returns the system-wide cookie handler or null if not set.
      • setDefault

        public static void setDefault​(CookieHandler cHandler)
        Sets the system-wide cookie handler.
      • get

        public abstract Map<String,​List<String>> get​(URI uri,
                                                           Map<String,​List<String>> requestHeaders)
                                                    throws IOException
        Gets all cookies for a specific URI from the cookie cache.
        Parameters:
        uri - a URI to search for applicable cookies.
        requestHeaders - a list of request headers.
        Returns:
        an unchangeable map of all appropriate cookies.
        Throws:
        IOException - if an error occurs during the I/O operation.
      • put

        public abstract void put​(URI uri,
                                 Map<String,​List<String>> responseHeaders)
                          throws IOException
        Sets all cookies of a specific URI in the responseHeaders into the cookie cache.
        Parameters:
        uri - the origin URI of the cookies.
        responseHeaders - a list of request headers.
        Throws:
        IOException - if an error occurs during the I/O operation.