Class CookieStore

java.lang.Object
com.mastfrog.netty.http.client.CookieStore
All Implemented Interfaces:
Iterable<io.netty.handler.codec.http.cookie.Cookie>

public final class CookieStore extends Object implements Iterable<io.netty.handler.codec.http.cookie.Cookie>
Stores cookies from responses and decorates requests with them where appropriate.
Author:
Tim Boudreau
  • Constructor Details

    • CookieStore

      public CookieStore(boolean checkDomain, boolean checkPath)
      Create a cookie store.
      Parameters:
      checkDomain - Ignore cookies with the wrong domain
      checkPath - Ignore cookies that do not match the path
    • CookieStore

      public CookieStore()
      Create a cookie store which will check domains and paths when adding cookies.
  • Method Details

    • checkDomain

      public CookieStore checkDomain()
    • dontCheckDomain

      public CookieStore dontCheckDomain()
    • size

      public int size()
    • isEmpty

      public boolean isEmpty()
    • checkPath

      public CookieStore checkPath()
      Returns a new CookieStore which will check the path parameter of cookies when deciding to add them to a request. This is the default.
      Returns:
      A new CookieStore
    • dontCheckPath

      public CookieStore dontCheckPath()
      Returns a new CookieStore which does not check the path parameter of cookies when deciding to add them to a request.
      Returns:
      A new CookieStore
    • errorHandler

      public CookieStore errorHandler(Receiver<Throwable> errorHandler)
      Add a handler which will be called if an exception is thrown when parsing cookies - i.e. a server gave an invalid value for the cookie header. If not set, the exception will be thrown.
      Parameters:
      errorHandler - An error handler
      Returns:
      this
    • get

      public String get(String name)
    • add

      public void add(io.netty.handler.codec.http.cookie.Cookie cookie)
    • remove

      public void remove(String name)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • iterator

      public Iterator<io.netty.handler.codec.http.cookie.Cookie> iterator()
      Specified by:
      iterator in interface Iterable<io.netty.handler.codec.http.cookie.Cookie>
    • store

      public void store(OutputStream out) throws IOException
      Throws:
      IOException
    • read

      public void read(InputStream in) throws IOException
      Throws:
      IOException
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object