Home / Function/ extractKeyValuePairs() — netty Function Reference

extractKeyValuePairs() — netty Function Reference

Architecture documentation for the extractKeyValuePairs() function in CookieDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  7ed26cac_407c_b1e7_ec80_dd3437b5d703["extractKeyValuePairs()"]
  841c58a8_6f5c_8c20_e8ec_e79013189bd7["CookieDecoder"]
  7ed26cac_407c_b1e7_ec80_dd3437b5d703 -->|defined in| 841c58a8_6f5c_8c20_e8ec_e79013189bd7
  e1c540fe_01b6_4343_87c4_733c1786c03f["doDecode()"]
  e1c540fe_01b6_4343_87c4_733c1786c03f -->|calls| 7ed26cac_407c_b1e7_ec80_dd3437b5d703
  style 7ed26cac_407c_b1e7_ec80_dd3437b5d703 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java lines 201–322

    private static void extractKeyValuePairs(
            final String header, final List<String> names, final List<String> values) {
        final int headerLen  = header.length();
        loop: for (int i = 0;;) {

            // Skip spaces and separators.
            for (;;) {
                if (i == headerLen) {
                    break loop;
                }
                switch (header.charAt(i)) {
                case '\t': case '\n': case 0x0b: case '\f': case '\r':
                case ' ':  case ',':  case ';':
                    i ++;
                    continue;
                }
                break;
            }

            // Skip '$'.
            for (;;) {
                if (i == headerLen) {
                    break loop;
                }
                if (header.charAt(i) == '$') {
                    i ++;
                    continue;
                }
                break;
            }

            String name;
            String value;

            if (i == headerLen) {
                name = null;
                value = null;
            } else {
                int newNameStart = i;
                keyValLoop: for (;;) {
                    switch (header.charAt(i)) {
                    case ';':
                        // NAME; (no value till ';')
                        name = header.substring(newNameStart, i);
                        value = null;
                        break keyValLoop;
                    case '=':
                        // NAME=VALUE
                        name = header.substring(newNameStart, i);
                        i ++;
                        if (i == headerLen) {
                            // NAME= (empty value, i.e. nothing after '=')
                            value = "";
                            break keyValLoop;
                        }

                        int newValueStart = i;
                        char c = header.charAt(i);
                        if (c == '"' || c == '\'') {
                            // NAME="VALUE" or NAME='VALUE'
                            StringBuilder newValueBuf = new StringBuilder(header.length() - i);
                            final char q = c;
                            boolean hadBackslash = false;
                            i ++;
                            for (;;) {
                                if (i == headerLen) {
                                    value = newValueBuf.toString();
                                    break keyValLoop;
                                }
                                if (hadBackslash) {
                                    hadBackslash = false;
                                    c = header.charAt(i ++);
                                    switch (c) {
                                    case '\\': case '"': case '\'':
                                        // Escape last backslash.
                                        newValueBuf.setCharAt(newValueBuf.length() - 1, c);
                                        break;
                                    default:
                                        // Do not escape last backslash.
                                        newValueBuf.append(c);
                                    }

Subdomains

Called By

Frequently Asked Questions

What does extractKeyValuePairs() do?
extractKeyValuePairs() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java.
Where is extractKeyValuePairs() defined?
extractKeyValuePairs() is defined in codec-http/src/main/java/io/netty/handler/codec/http/CookieDecoder.java at line 201.
What calls extractKeyValuePairs()?
extractKeyValuePairs() is called by 1 function(s): doDecode.

Analyze Your Own Codebase

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

Try Supermodel Free