Home / Class/ CookieUtil Class — netty Architecture

CookieUtil Class — netty Architecture

Architecture documentation for the CookieUtil class in CookieUtil.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  34792e02_6ae5_db2f_ef12_be8295c4d494["CookieUtil"]
  4267ade5_cfe3_452e_acfd_aeb03da15825["CookieUtil.java"]
  34792e02_6ae5_db2f_ef12_be8295c4d494 -->|defined in| 4267ade5_cfe3_452e_acfd_aeb03da15825
  6daa267c_6a1b_ec6d_94a6_b7d00725a838["BitSet()"]
  34792e02_6ae5_db2f_ef12_be8295c4d494 -->|method| 6daa267c_6a1b_ec6d_94a6_b7d00725a838
  e7bf151e_8151_dde1_846e_eacd23eec041["firstInvalidCookieNameOctet()"]
  34792e02_6ae5_db2f_ef12_be8295c4d494 -->|method| e7bf151e_8151_dde1_846e_eacd23eec041
  7357c6bf_0cc7_6ed3_f3de_d56ed690c688["firstInvalidCookieValueOctet()"]
  34792e02_6ae5_db2f_ef12_be8295c4d494 -->|method| 7357c6bf_0cc7_6ed3_f3de_d56ed690c688
  66ea8fd7_c732_27f2_b195_5624a3dc4d89["firstInvalidOctet()"]
  34792e02_6ae5_db2f_ef12_be8295c4d494 -->|method| 66ea8fd7_c732_27f2_b195_5624a3dc4d89
  b51a36e9_a801_9fdc_817c_2ed89ad72239["CharSequence()"]
  34792e02_6ae5_db2f_ef12_be8295c4d494 -->|method| b51a36e9_a801_9fdc_817c_2ed89ad72239
  b54da9f4_a59e_88c9_51d4_2f1742719fc6["CookieUtil()"]
  34792e02_6ae5_db2f_ef12_be8295c4d494 -->|method| b54da9f4_a59e_88c9_51d4_2f1742719fc6

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/CookieUtil.java lines 23–104

@Deprecated
final class CookieUtil {

    private static final BitSet VALID_COOKIE_VALUE_OCTETS = validCookieValueOctets();

    private static final BitSet VALID_COOKIE_NAME_OCTETS = validCookieNameOctets(VALID_COOKIE_VALUE_OCTETS);

    // US-ASCII characters excluding CTLs, whitespace, DQUOTE, comma, semicolon, and backslash
    private static BitSet validCookieValueOctets() {
        BitSet bits = new BitSet(8);
        for (int i = 35; i < 127; i++) {
            // US-ASCII characters excluding CTLs (%x00-1F / %x7F)
            bits.set(i);
        }
        bits.set('"', false);  // exclude DQUOTE = %x22
        bits.set(',', false);  // exclude comma = %x2C
        bits.set(';', false);  // exclude semicolon = %x3B
        bits.set('\\', false); // exclude backslash = %x5C
        return bits;
    }

    //    token          = 1*<any CHAR except CTLs or separators>
    //    separators     = "(" | ")" | "<" | ">" | "@"
    //                   | "," | ";" | ":" | "\" | <">
    //                   | "/" | "[" | "]" | "?" | "="
    //                   | "{" | "}" | SP | HT
    private static BitSet validCookieNameOctets(BitSet validCookieValueOctets) {
        BitSet bits = new BitSet(8);
        bits.or(validCookieValueOctets);
        bits.set('(', false);
        bits.set(')', false);
        bits.set('<', false);
        bits.set('>', false);
        bits.set('@', false);
        bits.set(':', false);
        bits.set('/', false);
        bits.set('[', false);
        bits.set(']', false);
        bits.set('?', false);
        bits.set('=', false);
        bits.set('{', false);
        bits.set('}', false);
        bits.set(' ', false);
        bits.set('\t', false);
        return bits;
    }

    static int firstInvalidCookieNameOctet(CharSequence cs) {
        return firstInvalidOctet(cs, VALID_COOKIE_NAME_OCTETS);
    }

    static int firstInvalidCookieValueOctet(CharSequence cs) {
        return firstInvalidOctet(cs, VALID_COOKIE_VALUE_OCTETS);
    }

    static int firstInvalidOctet(CharSequence cs, BitSet bits) {
        for (int i = 0; i < cs.length(); i++) {
            char c = cs.charAt(i);
            if (!bits.get(c)) {
                return i;
            }
        }
        return -1;
    }

    static CharSequence unwrapValue(CharSequence cs) {
        final int len = cs.length();
        if (len > 0 && cs.charAt(0) == '"') {
            if (len >= 2 && cs.charAt(len - 1) == '"') {
                // properly balanced
                return len == 2 ? "" : cs.subSequence(1, len - 1);
            } else {
                return null;
            }
        }
        return cs;
    }

    private CookieUtil() {
        // Unused
    }

Frequently Asked Questions

What is the CookieUtil class?
CookieUtil is a class in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/CookieUtil.java.
Where is CookieUtil defined?
CookieUtil is defined in codec-http/src/main/java/io/netty/handler/codec/http/CookieUtil.java at line 23.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free