Home / Function/ ByteBuf() — netty Function Reference

ByteBuf() — netty Function Reference

Architecture documentation for the ByteBuf() function in SpdyHeaderBlockRawEncoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  346bbbdc_8353_abb3_ea8b_fd4cc9477692["ByteBuf()"]
  97b5c3ea_7587_8c16_eff5_c798ca2e3734["SpdyHeaderBlockRawEncoder"]
  346bbbdc_8353_abb3_ea8b_fd4cc9477692 -->|defined in| 97b5c3ea_7587_8c16_eff5_c798ca2e3734
  89f3ce9a_e579_d18e_7ae9_3ef83231fd39["writeLengthField()"]
  346bbbdc_8353_abb3_ea8b_fd4cc9477692 -->|calls| 89f3ce9a_e579_d18e_7ae9_3ef83231fd39
  a1ce5bdc_5258_c150_df1b_5bb3a5cc7294["setLengthField()"]
  346bbbdc_8353_abb3_ea8b_fd4cc9477692 -->|calls| a1ce5bdc_5258_c150_df1b_5bb3a5cc7294
  style 346bbbdc_8353_abb3_ea8b_fd4cc9477692 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawEncoder.java lines 44–84

    @Override
    public ByteBuf encode(ByteBufAllocator alloc, SpdyHeadersFrame frame) throws Exception {
        Set<CharSequence> names = frame.headers().names();
        int numHeaders = names.size();
        if (numHeaders == 0) {
            return Unpooled.EMPTY_BUFFER;
        }
        if (numHeaders > SPDY_MAX_NV_LENGTH) {
            throw new IllegalArgumentException(
                    "header block contains too many headers");
        }
        ByteBuf headerBlock = alloc.heapBuffer();
        writeLengthField(headerBlock, numHeaders);
        for (CharSequence name: names) {
            writeLengthField(headerBlock, name.length());
            ByteBufUtil.writeAscii(headerBlock, name);
            int savedIndex = headerBlock.writerIndex();
            int valueLength = 0;
            writeLengthField(headerBlock, valueLength);
            for (CharSequence value: frame.headers().getAll(name)) {
                int length = value.length();
                if (length > 0) {
                    ByteBufUtil.writeAscii(headerBlock, value);
                    headerBlock.writeByte(0);
                    valueLength += length + 1;
                }
            }
            if (valueLength != 0) {
                valueLength --;
            }
            if (valueLength > SPDY_MAX_NV_LENGTH) {
                throw new IllegalArgumentException(
                        "header exceeds allowable length: " + name);
            }
            if (valueLength > 0) {
                setLengthField(headerBlock, savedIndex, valueLength);
                headerBlock.writerIndex(headerBlock.writerIndex() - 1);
            }
        }
        return headerBlock;
    }

Domain

Subdomains

Frequently Asked Questions

What does ByteBuf() do?
ByteBuf() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawEncoder.java.
Where is ByteBuf() defined?
ByteBuf() is defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawEncoder.java at line 44.
What does ByteBuf() call?
ByteBuf() calls 2 function(s): setLengthField, writeLengthField.

Analyze Your Own Codebase

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

Try Supermodel Free