Home / Class/ ContentLength Class — netty Architecture

ContentLength Class — netty Architecture

Architecture documentation for the ContentLength class in DefaultHttp2ConnectionDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  cfd8223c_5f61_2fca_8425_a5a38fb3c92c["ContentLength"]
  a43ecbf7_4477_1770_e9bd_6bd36bd824e3["DefaultHttp2ConnectionDecoder.java"]
  cfd8223c_5f61_2fca_8425_a5a38fb3c92c -->|defined in| a43ecbf7_4477_1770_e9bd_6bd36bd824e3
  89b3c4dc_6b2d_611c_6134_43390f8dfb50["ContentLength()"]
  cfd8223c_5f61_2fca_8425_a5a38fb3c92c -->|method| 89b3c4dc_6b2d_611c_6134_43390f8dfb50
  58013060_d6e1_1a48_4dbc_eb77bb9f66cf["increaseReceivedBytes()"]
  cfd8223c_5f61_2fca_8425_a5a38fb3c92c -->|method| 58013060_d6e1_1a48_4dbc_eb77bb9f66cf

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoder.java lines 800–834

    private static final class ContentLength {
        private final long expected;
        private long seen;

        ContentLength(long expected) {
            this.expected = expected;
        }

        void increaseReceivedBytes(boolean server, int streamId, int bytes, boolean isEnd) throws Http2Exception {
            seen += bytes;
            // Check for overflow
            if (seen < 0) {
                throw streamError(streamId, PROTOCOL_ERROR,
                        "Received amount of data did overflow and so not match content-length header %d", expected);
            }
            // Check if we received more data then what was advertised via the content-length header.
            if (seen > expected) {
                throw streamError(streamId, PROTOCOL_ERROR,
                        "Received amount of data %d does not match content-length header %d", seen, expected);
            }

            if (isEnd) {
                if (seen == 0 && !server) {
                    // This may be a response to a HEAD request, let's just allow it.
                    return;
                }

                // Check that we really saw what was told via the content-length header.
                if (expected > seen) {
                    throw streamError(streamId, PROTOCOL_ERROR,
                            "Received amount of data %d does not match content-length header %d", seen, expected);
                }
            }
        }
    }

Frequently Asked Questions

What is the ContentLength class?
ContentLength is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoder.java.
Where is ContentLength defined?
ContentLength is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoder.java at line 800.

Analyze Your Own Codebase

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

Try Supermodel Free