Home / Function/ DefaultCookie() — netty Function Reference

DefaultCookie() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  12469b5c_12b8_1f54_4815_1e5d252192ed["DefaultCookie()"]
  405ab980_179f_09fe_5123_8cd4c64546d6["CookieDecoder"]
  12469b5c_12b8_1f54_4815_1e5d252192ed -->|defined in| 405ab980_179f_09fe_5123_8cd4c64546d6
  style 12469b5c_12b8_1f54_4815_1e5d252192ed fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/cookie/CookieDecoder.java lines 40–83

    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;
    }

Subdomains

Frequently Asked Questions

What does DefaultCookie() do?
DefaultCookie() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/cookie/CookieDecoder.java.
Where is DefaultCookie() defined?
DefaultCookie() is defined in codec-http/src/main/java/io/netty/handler/codec/http/cookie/CookieDecoder.java at line 40.

Analyze Your Own Codebase

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

Try Supermodel Free