Home / Function/ LastHttpContent() — netty Function Reference

LastHttpContent() — netty Function Reference

Architecture documentation for the LastHttpContent() function in HttpObjectDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  ae0e6d22_7857_48d7_2163_e474a9e3073b["LastHttpContent()"]
  6c551372_1bb2_fe27_3884_c4cc297c86ae["HttpObjectDecoder"]
  ae0e6d22_7857_48d7_2163_e474a9e3073b -->|defined in| 6c551372_1bb2_fe27_3884_c4cc297c86ae
  40673f8f_e843_c287_a057_291f8aa2ac4d["splitHeader()"]
  ae0e6d22_7857_48d7_2163_e474a9e3073b -->|calls| 40673f8f_e843_c287_a057_291f8aa2ac4d
  style ae0e6d22_7857_48d7_2163_e474a9e3073b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java lines 856–910

    private LastHttpContent readTrailingHeaders(ByteBuf buffer) {
        final HeaderParser headerParser = this.headerParser;
        ByteBuf line = headerParser.parse(buffer, defaultStrictCRLFCheck);
        if (line == null) {
            return null;
        }
        LastHttpContent trailer = this.trailer;
        int lineLength = line.readableBytes();
        if (lineLength == 0 && trailer == null) {
            // We have received the empty line which signals the trailer is complete and did not parse any trailers
            // before. Just return an empty last content to reduce allocations.
            return LastHttpContent.EMPTY_LAST_CONTENT;
        }

        CharSequence lastHeader = null;
        if (trailer == null) {
            trailer = this.trailer = new DefaultLastHttpContent(Unpooled.EMPTY_BUFFER, trailersFactory);
        }
        while (lineLength > 0) {
            final byte[] lineContent = line.array();
            final int startLine = line.arrayOffset() + line.readerIndex();
            final byte firstChar = lineContent[startLine];
            if (lastHeader != null && (firstChar == ' ' || firstChar == '\t')) {
                List<String> current = trailer.trailingHeaders().getAll(lastHeader);
                if (!current.isEmpty()) {
                    int lastPos = current.size() - 1;
                    //please do not make one line from below code
                    //as it breaks +XX:OptimizeStringConcat optimization
                    String lineTrimmed = langAsciiString(lineContent, startLine, line.readableBytes()).trim();
                    String currentLastPos = current.get(lastPos);
                    current.set(lastPos, currentLastPos + lineTrimmed);
                }
            } else {
                splitHeader(lineContent, startLine, lineLength);
                AsciiString headerName = name;
                if (!HttpHeaderNames.CONTENT_LENGTH.contentEqualsIgnoreCase(headerName) &&
                        !HttpHeaderNames.TRANSFER_ENCODING.contentEqualsIgnoreCase(headerName) &&
                        !HttpHeaderNames.TRAILER.contentEqualsIgnoreCase(headerName)) {
                    trailer.trailingHeaders().add(headerName, value);
                }
                lastHeader = name;
                // reset name and value fields
                name = null;
                value = null;
            }
            line = headerParser.parse(buffer, defaultStrictCRLFCheck);
            if (line == null) {
                return null;
            }
            lineLength = line.readableBytes();
        }

        this.trailer = null;
        return trailer;
    }

Subdomains

Frequently Asked Questions

What does LastHttpContent() do?
LastHttpContent() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java.
Where is LastHttpContent() defined?
LastHttpContent() is defined in codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java at line 856.
What does LastHttpContent() call?
LastHttpContent() calls 1 function(s): splitHeader.

Analyze Your Own Codebase

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

Try Supermodel Free