Class NettyCookie

java.lang.Object
io.micronaut.http.netty.cookies.NettyCookie
All Implemented Interfaces:
Cookie, Serializable, Comparable<Cookie>

@Internal public class NettyCookie extends Object implements Cookie
A wrapper around a Netty cookie.
Since:
1.0
Author:
Graeme Rocher
See Also:
  • Constructor Details

    • NettyCookie

      public NettyCookie(io.netty.handler.codec.http.cookie.Cookie nettyCookie)
      Parameters:
      nettyCookie - The Netty cookie
    • NettyCookie

      public NettyCookie(String name, String value)
      Parameters:
      name - The name
      value - The value
    • NettyCookie

      public NettyCookie(Cookie cookie)
      Parameters:
      cookie - Micronaut Cookie
  • Method Details

    • getNettyCookie

      public io.netty.handler.codec.http.cookie.Cookie getNettyCookie()
      Returns:
      The Netty cookie
    • getName

      @NonNull public @NonNull String getName()
      Specified by:
      getName in interface Cookie
      Returns:
      The name of the cookie
    • getValue

      @NonNull public @NonNull String getValue()
      Specified by:
      getValue in interface Cookie
      Returns:
      The value of the cookie
    • getDomain

      public String getDomain()
      Description copied from interface: Cookie
      Gets the domain name of this Cookie.

      Domain names are formatted according to RFC 2109.

      Specified by:
      getDomain in interface Cookie
      Returns:
      the domain name of this Cookie
    • getPath

      public String getPath()
      Description copied from interface: Cookie
      The path of the cookie. The cookie is visible to all paths below the request path on the server.
      Specified by:
      getPath in interface Cookie
      Returns:
      The cookie path
    • isHttpOnly

      public boolean isHttpOnly()
      Description copied from interface: Cookie
      Checks to see if this Cookie can only be accessed via HTTP. If this returns true, the Cookie cannot be accessed through client side script - But only if the browser supports it.

      See here for reference

      Specified by:
      isHttpOnly in interface Cookie
      Returns:
      True if this Cookie is HTTP-only or false if it isn't
    • isSecure

      public boolean isSecure()
      Specified by:
      isSecure in interface Cookie
      Returns:
      True if the cookie is secure
    • getMaxAge

      public long getMaxAge()
      Description copied from interface: Cookie
      Gets the maximum age of the cookie in seconds. If the max age has not been explicitly set, then the value returned will be Cookie.UNDEFINED_MAX_AGE, indicating that the Max-Age Attribute should not be written.
      Specified by:
      getMaxAge in interface Cookie
      Returns:
      The maximum age of the cookie in seconds
    • maxAge

      @NonNull public @NonNull Cookie maxAge(long maxAge)
      Description copied from interface: Cookie
      Sets the max age of the cookie in seconds. When not explicitly set, the max age will default to Cookie.UNDEFINED_MAX_AGE and cause the Max-Age Attribute not to be encoded.
      Specified by:
      maxAge in interface Cookie
      Parameters:
      maxAge - The max age
      Returns:
      This cookie
    • getSameSite

      public Optional<SameSite> getSameSite()
      Description copied from interface: Cookie
      Checks to see if this Cookie can be sent along cross-site requests. For more information, please look here
      Specified by:
      getSameSite in interface Cookie
      Returns:
      The SameSite attribute of the cookie
    • sameSite

      @NonNull public @NonNull Cookie sameSite(@Nullable @Nullable SameSite sameSite)
      Description copied from interface: Cookie
      Determines if this Cookie can be sent along cross-site requests. For more information, please look here
      Specified by:
      sameSite in interface Cookie
      Parameters:
      sameSite - SameSite value
      Returns:
      This cookie
    • value

      Description copied from interface: Cookie
      Sets the value.
      Specified by:
      value in interface Cookie
      Parameters:
      value - The value of the cookie
      Returns:
      This cookie
    • domain

      @NonNull public @NonNull Cookie domain(String domain)
      Description copied from interface: Cookie
      Sets the domain of the cookie.
      Specified by:
      domain in interface Cookie
      Parameters:
      domain - The domain of the cookie
      Returns:
      This cookie
    • path

      @NonNull public @NonNull Cookie path(String path)
      Description copied from interface: Cookie
      Sets the path of the cookie.
      Specified by:
      path in interface Cookie
      Parameters:
      path - The path of the cookie
      Returns:
      This cookie
    • secure

      @NonNull public @NonNull Cookie secure(boolean secure)
      Description copied from interface: Cookie
      Sets whether the cookie is secure.
      Specified by:
      secure in interface Cookie
      Parameters:
      secure - Is the cookie secure
      Returns:
      This cookie
    • httpOnly

      @NonNull public @NonNull Cookie httpOnly(boolean httpOnly)
      Description copied from interface: Cookie
      Sets whether the cookie is HTTP-Only.
      Specified by:
      httpOnly in interface Cookie
      Parameters:
      httpOnly - Is the cookie HTTP-Only
      Returns:
      This cookie
    • compareTo

      public int compareTo(Cookie o)
      Specified by:
      compareTo in interface Comparable<Cookie>