public String generateHeader()

in aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsCookieProcessor.java [107:159]


    public String generateHeader(Cookie cookie) {
        StringBuilder header = new StringBuilder();
        header.append(cookie.getName()).append('=');

        String value = cookie.getValue();
        if (value != null && value.length() > 0) {
            validateCookieValue(value);
            header.append(value);
        }

        int maxAge = cookie.getMaxAge();
        if (maxAge == 0) {
            appendAttribute(header, COOKIE_EXPIRES_ATTR, ANCIENT_DATE);
        } else if (maxAge > 0){
            Instant expiresAt = Instant.now().plusSeconds(maxAge);
            appendAttribute(header, COOKIE_EXPIRES_ATTR, COOKIE_DATE_FORMATTER.format(expiresAt));
            appendAttribute(header, COOKIE_MAX_AGE_ATTR, String.valueOf(maxAge));
        }

        String domain = cookie.getDomain();
        if (domain != null && !domain.isEmpty()) {
            validateDomain(domain);
            appendAttribute(header, COOKIE_DOMAIN_ATTR, domain);
        }

        String path = cookie.getPath();
        if (path != null && !path.isEmpty()) {
            validatePath(path);
            appendAttribute(header, COOKIE_PATH_ATTR, path);
        }

        if (cookie.getSecure()) {
            appendAttributeWithoutValue(header, COOKIE_SECURE_ATTR);
        }

        if (cookie.isHttpOnly()) {
            appendAttributeWithoutValue(header, COOKIE_HTTP_ONLY_ATTR);
        }

        String sameSite = cookie.getAttribute(COOKIE_SAME_SITE_ATTR);
        if (sameSite != null) {
            appendAttribute(header, COOKIE_SAME_SITE_ATTR, sameSite);
        }

        String partitioned = cookie.getAttribute(COOKIE_PARTITIONED_ATTR);
        if (EMPTY_STRING.equals(partitioned)) {
            appendAttributeWithoutValue(header, COOKIE_PARTITIONED_ATTR);
        }

        addAdditionalAttributes(cookie, header);

        return header.toString();
    }