Home / Function/ ByteBuf() — netty Function Reference

ByteBuf() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  8d7d3ab9_dfc3_34dd_a261_4cec62c8a737["ByteBuf()"]
  3e2d1413_1ae5_e37c_290b_57bfb2bcef3b["DeflateEncoder"]
  8d7d3ab9_dfc3_34dd_a261_4cec62c8a737 -->|defined in| 3e2d1413_1ae5_e37c_290b_57bfb2bcef3b
  26a67d80_d395_9e0d_89dd_ee6bdf9c7f91["cleanup()"]
  8d7d3ab9_dfc3_34dd_a261_4cec62c8a737 -->|calls| 26a67d80_d395_9e0d_89dd_ee6bdf9c7f91
  c9f595db_eee6_5a26_839f_89649b69e378["removeFrameTail()"]
  8d7d3ab9_dfc3_34dd_a261_4cec62c8a737 -->|calls| c9f595db_eee6_5a26_839f_89649b69e378
  style 8d7d3ab9_dfc3_34dd_a261_4cec62c8a737 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateEncoder.java lines 118–159

    private ByteBuf compressContent(ChannelHandlerContext ctx, WebSocketFrame msg) {
        if (encoder == null) {
            encoder = EmbeddedChannel.builder()
                    .handlers(ZlibCodecFactory.newZlibEncoder(
                            ZlibWrapper.NONE, compressionLevel, windowSize, 8))
                    .build();
        }

        encoder.writeOutbound(msg.content().retain());

        CompositeByteBuf fullCompressedContent = ctx.alloc().compositeBuffer();
        for (;;) {
            ByteBuf partCompressedContent = encoder.readOutbound();
            if (partCompressedContent == null) {
                break;
            }
            if (!partCompressedContent.isReadable()) {
                partCompressedContent.release();
                continue;
            }
            fullCompressedContent.addComponent(true, partCompressedContent);
        }

        if (fullCompressedContent.numComponents() <= 0) {
            fullCompressedContent.release();
            throw new CodecException("cannot read compressed buffer");
        }

        if (msg.isFinalFragment() && noContext) {
            cleanup();
        }

        ByteBuf compressedContent;
        if (removeFrameTail(msg)) {
            int realLength = fullCompressedContent.readableBytes() - FRAME_TAIL.readableBytes();
            compressedContent = fullCompressedContent.slice(0, realLength);
        } else {
            compressedContent = fullCompressedContent;
        }

        return compressedContent;
    }

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/http/websocketx/extensions/compression/DeflateEncoder.java.
Where is ByteBuf() defined?
ByteBuf() is defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/extensions/compression/DeflateEncoder.java at line 118.
What does ByteBuf() call?
ByteBuf() calls 2 function(s): cleanup, removeFrameTail.

Analyze Your Own Codebase

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

Try Supermodel Free