Package fi.iki.elonen

Class NanoHTTPD.CookieHandler

java.lang.Object
fi.iki.elonen.NanoHTTPD.CookieHandler
All Implemented Interfaces:
Iterable<String>
Enclosing class:
NanoHTTPD

public class NanoHTTPD.CookieHandler extends Object implements Iterable<String>
Provides rudimentary support for cookies. Doesn't support 'path', 'secure' nor 'httpOnly'. Feel free to improve it and/or add unsupported features.
  • Field Details

  • Constructor Details

  • Method Details

    • delete

      public void delete(String name)
      Set a cookie with an expiration date from a month ago, effectively deleting it on the client side.
      Parameters:
      name - The cookie name.
    • iterator

      public Iterator<String> iterator()
      Specified by:
      iterator in interface Iterable<String>
    • read

      public String read(String name)
      Read a cookie from the HTTP Headers.
      Parameters:
      name - The cookie's name.
      Returns:
      The cookie's value if it exists, null otherwise.
    • set

      public void set(NanoHTTPD.Cookie cookie)
    • set

      public void set(String name, String value, int expires)
      Sets a cookie.
      Parameters:
      name - The cookie's name.
      value - The cookie's value.
      expires - How many days until the cookie expires.
    • unloadQueue

      public void unloadQueue(NanoHTTPD.Response response)
      Internally used by the webserver to add all queued cookies into the Response's HTTP Headers.
      Parameters:
      response - The Response object to which headers the queued cookies will be added.