Top Methods
org.apache.tomcat.util.http

public Interface CookieProcessor

Known Direct Implementers
org.apache.tomcat.util.http.CookieProcessorBase
Imports
java.nio.charset.Charset, jakarta.servlet.http.Cookie, .HttpServletRequest

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The header value in a form that can be added directly to the response
generateHeader
(Cookie
The cookie for which the header will be generated
cookie
,
HttpServletRequest
The servlet request
request
)

Generate the Set-Cookie HTTP header value for the given Cookie.

public Charset

Returns:

The character set used for byte<->character conversions
getCharset
()

Obtain the character set that will be used when converting between bytes and characters when parsing and/or generating HTTP headers for cookies.

public void
parseCookieHeader(MimeHeaders
The HTTP headers to parse
headers
,
ServerCookies
The server cookies object to populate with the results of the parsing
serverCookies
)

Parse the provided headers into server cookie objects.

Method Detail

generateHeaderback to summary
public 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.

Parameters
cookie:Cookie

The cookie for which the header will be generated

request:HttpServletRequest

The servlet request

Returns:String

The header value in a form that can be added directly to the response

getCharsetback to summary
public 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:Charset

The character set used for byte<->character conversions

parseCookieHeaderback to summary
public void parseCookieHeader(MimeHeaders headers, ServerCookies serverCookies)

Parse the provided headers into server cookie objects.

Parameters
headers:MimeHeaders

The HTTP headers to parse

serverCookies:ServerCookies

The server cookies object to populate with the results of the parsing