org.apache.tomcat.util.http

## Interface CookieProcessor

- All Known Implementing Classes:
    CookieProcessorBase, LegacyCookieProcessor, Rfc6265CookieProcessor

      public interface CookieProcessor

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `generateHeader(Cookie cookie)` Deprecated. This method has been replaced with `generateHeader(Cookie, HttpServletRequest)` and will be removed from Tomcat 10 onwards.
    `default String` | `generateHeader(Cookie cookie, HttpServletRequest request)` Generate the `Set-Cookie` HTTP header value for the given Cookie.
    `Charset` | `getCharset()` Obtain the character set that will be used when converting between bytes and characters when parsing and/or generating HTTP headers for cookies.
    `void` | `parseCookieHeader(MimeHeaders headers, ServerCookies serverCookies)` Parse the provided headers into server cookie objects.

- - ### Method Detail

    - #### parseCookieHeader

          void parseCookieHeader(MimeHeaders headers,
                                 ServerCookies serverCookies)

      Parse the provided headers into server cookie objects.
      Parameters:
        `headers` - The HTTP headers to parse
        `serverCookies` - The server cookies object to populate with the results of the parsing

    - #### generateHeader

          @Deprecated
          String generateHeader(Cookie cookie)

      Deprecated. This method has been replaced with `generateHeader(Cookie, HttpServletRequest)` and will be removed from Tomcat 10 onwards.
      Generate the `Set-Cookie` HTTP header value for the given Cookie.
      Parameters:
        `cookie` - The cookie for which the header will be generated
      Returns:
        The header value in a form that can be added directly to the response

    - #### generateHeader

          default String generateHeader(Cookie cookie,
                                        HttpServletRequest request)

      Generate the `Set-Cookie` HTTP header value for the given Cookie. This method receives as parameter the servlet request so that it can make decisions based on request properties. One such use-case is decide if the SameSite attribute should be added to the cookie based on the User-Agent or other request header because there are browser versions incompatible with the SameSite attribute. This is described by the Chromium project.

      The default implementation calls the deprecated `generateHeader(Cookie)` method. Implementors should not rely on this default method as it is present only for transitional compatibility and will be removed in Tomcat 10 at the same time as the `generateHeader(Cookie)` method.

      Parameters:
        `request` - The servlet request
        `cookie` - The cookie for which the header will be generated
      Returns:
        The header value in a form that can be added directly to the response

    - #### getCharset

          Charset getCharset()

      Obtain the character set that will be used when converting between bytes and characters when parsing and/or generating HTTP headers for cookies.
      Returns:
        The character set used for byte<->character conversions

Copyright © 2000-2022 Apache Software Foundation. All Rights Reserved.