Home / Function/ sanitizeHeadersBeforeEncode() — netty Function Reference

sanitizeHeadersBeforeEncode() — netty Function Reference

Architecture documentation for the sanitizeHeadersBeforeEncode() function in HttpResponseEncoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  f93dc19a_4424_c8c5_bed9_e10fd1a511b0["sanitizeHeadersBeforeEncode()"]
  bcdc6576_85d8_9fc4_6f59_ed2fc79de374["HttpResponseEncoder"]
  f93dc19a_4424_c8c5_bed9_e10fd1a511b0 -->|defined in| bcdc6576_85d8_9fc4_6f59_ed2fc79de374
  style f93dc19a_4424_c8c5_bed9_e10fd1a511b0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseEncoder.java lines 52–76

    @Override
    protected void sanitizeHeadersBeforeEncode(HttpResponse msg, boolean isAlwaysEmpty) {
        if (isAlwaysEmpty) {
            HttpResponseStatus status = msg.status();
            if (status.codeClass() == HttpStatusClass.INFORMATIONAL ||
                    status.code() == HttpResponseStatus.NO_CONTENT.code()) {

                // Stripping Content-Length:
                // See https://tools.ietf.org/html/rfc7230#section-3.3.2
                msg.headers().remove(HttpHeaderNames.CONTENT_LENGTH);

                // Stripping Transfer-Encoding:
                // See https://tools.ietf.org/html/rfc7230#section-3.3.1
                msg.headers().remove(HttpHeaderNames.TRANSFER_ENCODING);
            } else if (status.code() == HttpResponseStatus.RESET_CONTENT.code()) {

                // Stripping Transfer-Encoding:
                msg.headers().remove(HttpHeaderNames.TRANSFER_ENCODING);

                // Set Content-Length: 0
                // https://httpstatuses.com/205
                msg.headers().setInt(HttpHeaderNames.CONTENT_LENGTH, 0);
            }
        }
    }

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free