Home / Class/ ClientCookieDecoder Class — netty Architecture

ClientCookieDecoder Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  5cceca96_9ac8_6942_9ebd_814142e85ca4["ClientCookieDecoder"]
  e327414f_4b94_95f7_3704_b6b4e2d85cc3["ClientCookieDecoder.java"]
  5cceca96_9ac8_6942_9ebd_814142e85ca4 -->|defined in| e327414f_4b94_95f7_3704_b6b4e2d85cc3
  d8e806af_925d_049e_7a3e_d735534db3fb["ClientCookieDecoder()"]
  5cceca96_9ac8_6942_9ebd_814142e85ca4 -->|method| d8e806af_925d_049e_7a3e_d735534db3fb
  c93972ed_7edc_39c6_c802_7e2823875549["Cookie()"]
  5cceca96_9ac8_6942_9ebd_814142e85ca4 -->|method| c93972ed_7edc_39c6_c802_7e2823875549

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/cookie/ClientCookieDecoder.java lines 33–273

public final class ClientCookieDecoder extends CookieDecoder {

    /**
     * Strict encoder that validates that name and value chars are in the valid scope
     * defined in RFC6265
     */
    public static final ClientCookieDecoder STRICT = new ClientCookieDecoder(true);

    /**
     * Lax instance that doesn't validate name and value
     */
    public static final ClientCookieDecoder LAX = new ClientCookieDecoder(false);

    private ClientCookieDecoder(boolean strict) {
        super(strict);
    }

    /**
     * Decodes the specified Set-Cookie HTTP header value into a {@link Cookie}.
     *
     * @return the decoded {@link Cookie}
     */
    public Cookie decode(String header) {
        final int headerLen = checkNotNull(header, "header").length();

        if (headerLen == 0) {
            return null;
        }

        CookieBuilder cookieBuilder = null;

        loop: for (int i = 0;;) {

            // Skip spaces and separators.
            for (;;) {
                if (i == headerLen) {
                    break loop;
                }
                char c = header.charAt(i);
                if (c == ',') {
                    // Having multiple cookies in a single Set-Cookie header is
                    // deprecated, modern browsers only parse the first one
                    break loop;

                } else if (c == '\t' || c == '\n' || c == 0x0b || c == '\f'
                        || c == '\r' || c == ' ' || c == ';') {
                    i++;
                    continue;
                }
                break;
            }

            int nameBegin = i;
            int nameEnd;
            int valueBegin;
            int valueEnd;

            for (;;) {
                char curChar = header.charAt(i);
                if (curChar == ';') {
                    // NAME; (no value till ';')
                    nameEnd = i;
                    valueBegin = valueEnd = -1;
                    break;

                } else if (curChar == '=') {
                    // NAME=VALUE
                    nameEnd = i;
                    i++;
                    if (i == headerLen) {
                        // NAME= (empty value, i.e. nothing after '=')
                        valueBegin = valueEnd = 0;
                        break;
                    }

                    valueBegin = i;
                    // NAME=VALUE;
                    int semiPos = header.indexOf(';', i);
                    valueEnd = i = semiPos > 0 ? semiPos : headerLen;
                    break;
                } else {

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free