Home / Function/ String() — netty Function Reference

String() — netty Function Reference

Architecture documentation for the String() function in HttpContentCompressor.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a15b132b_a186_c83b_c808_35e1c94c6bae["String()"]
  1a373d52_2146_2610_7650_6b487cdcefae["HttpContentCompressor"]
  a15b132b_a186_c83b_c808_35e1c94c6bae -->|defined in| 1a373d52_2146_2610_7650_6b487cdcefae
  style a15b132b_a186_c83b_c808_35e1c94c6bae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/HttpContentCompressor.java lines 328–401

    @SuppressWarnings("FloatingPointEquality")
    protected String determineEncoding(String acceptEncoding) {
        float starQ = -1.0f;
        float brQ = -1.0f;
        float zstdQ = -1.0f;
        float snappyQ = -1.0f;
        float gzipQ = -1.0f;
        float deflateQ = -1.0f;

        int start = 0;
        int length = acceptEncoding.length();
        while (start < length) {
            int comma = acceptEncoding.indexOf(',', start);
            if (comma == -1) {
                comma = length;
            }
            String encoding = acceptEncoding.substring(start, comma);
            float q = 1.0f;
            int equalsPos = encoding.indexOf('=');
            if (equalsPos != -1) {
                try {
                    q = Float.parseFloat(encoding.substring(equalsPos + 1));
                } catch (NumberFormatException e) {
                    // Ignore encoding
                    q = 0.0f;
                }
            }
            if (encoding.contains("*")) {
                starQ = q;
            } else if (encoding.contains("br") && q > brQ) {
                brQ = q;
            } else if (encoding.contains("zstd") && q > zstdQ) {
                zstdQ = q;
            } else if (encoding.contains("snappy") && q > snappyQ) {
                snappyQ = q;
            } else if (encoding.contains("gzip") && q > gzipQ) {
                gzipQ = q;
            } else if (encoding.contains("deflate") && q > deflateQ) {
                deflateQ = q;
            }
            start = comma + 1;
        }
        if (brQ > 0.0f || zstdQ > 0.0f || snappyQ > 0.0f || gzipQ > 0.0f || deflateQ > 0.0f) {
            if (brQ != -1.0f && brQ >= zstdQ && this.brotliOptions != null) {
                return "br";
            } else if (zstdQ != -1.0f && zstdQ >= snappyQ && this.zstdOptions != null) {
                return "zstd";
            } else if (snappyQ != -1.0f && snappyQ >= gzipQ && this.snappyOptions != null) {
                return "snappy";
            } else if (gzipQ != -1.0f && gzipQ >= deflateQ && this.gzipOptions != null) {
                return "gzip";
            } else if (deflateQ != -1.0f && this.deflateOptions != null) {
                return "deflate";
            }
        }
        if (starQ > 0.0f) {
            if (brQ == -1.0f && this.brotliOptions != null) {
                return "br";
            }
            if (zstdQ == -1.0f && this.zstdOptions != null) {
                return "zstd";
            }
            if (snappyQ == -1.0f && this.snappyOptions != null) {
                return "snappy";
            }
            if (gzipQ == -1.0f && this.gzipOptions != null) {
                return "gzip";
            }
            if (deflateQ == -1.0f && this.deflateOptions != null) {
                return "deflate";
            }
        }
        return null;
    }

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free