Home / Class/ CookieDecoder Class — netty Architecture

CookieDecoder Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  405ab980_179f_09fe_5123_8cd4c64546d6["CookieDecoder"]
  9476703b_7264_e88d_9add_2cd1e0e09595["CookieDecoder.java"]
  405ab980_179f_09fe_5123_8cd4c64546d6 -->|defined in| 9476703b_7264_e88d_9add_2cd1e0e09595
  2e9789ce_1ba9_8c5d_f597_7ec74ec7e403["CookieDecoder()"]
  405ab980_179f_09fe_5123_8cd4c64546d6 -->|method| 2e9789ce_1ba9_8c5d_f597_7ec74ec7e403
  12469b5c_12b8_1f54_4815_1e5d252192ed["DefaultCookie()"]
  405ab980_179f_09fe_5123_8cd4c64546d6 -->|method| 12469b5c_12b8_1f54_4815_1e5d252192ed

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/cookie/CookieDecoder.java lines 30–84

public abstract class CookieDecoder {

    private final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());

    private final boolean strict;

    protected CookieDecoder(boolean strict) {
        this.strict = strict;
    }

    protected DefaultCookie initCookie(String header, int nameBegin, int nameEnd, int valueBegin, int valueEnd) {
        if (nameBegin == -1 || nameBegin == nameEnd) {
            logger.debug("Skipping cookie with null name");
            return null;
        }

        if (valueBegin == -1) {
            logger.debug("Skipping cookie with null value");
            return null;
        }

        CharSequence wrappedValue = CharBuffer.wrap(header, valueBegin, valueEnd);
        CharSequence unwrappedValue = unwrapValue(wrappedValue);
        if (unwrappedValue == null) {
            logger.debug("Skipping cookie because starting quotes are not properly balanced in '{}'",
                    wrappedValue);
            return null;
        }

        final String name = header.substring(nameBegin, nameEnd);

        int invalidOctetPos;
        if (strict && (invalidOctetPos = firstInvalidCookieNameOctet(name)) >= 0) {
            if (logger.isDebugEnabled()) {
                logger.debug("Skipping cookie because name '{}' contains invalid char '{}'",
                        name, name.charAt(invalidOctetPos));
            }
            return null;
        }

        final boolean wrap = unwrappedValue.length() != valueEnd - valueBegin;

        if (strict && (invalidOctetPos = firstInvalidCookieValueOctet(unwrappedValue)) >= 0) {
            if (logger.isDebugEnabled()) {
                logger.debug("Skipping cookie because value '{}' contains invalid char '{}'",
                        unwrappedValue, unwrappedValue.charAt(invalidOctetPos));
            }
            return null;
        }

        DefaultCookie cookie = new DefaultCookie(name, unwrappedValue.toString());
        cookie.setWrap(wrap);
        return cookie;
    }
}

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free