private boolean shouldEncodeResponse(ResponseHeaders headers) {
        if (headers.status().isContentAlwaysEmpty()) {
            return false;
        }
        if (headers.contains(HttpHeaderNames.CONTENT_ENCODING)) {
            // We don't do automatic encoding if the user-supplied headers contain
            // Content-Encoding.
            return false;
        }
        if (headers.contentType() != null) {
            // Make sure the content type is worth encoding.
            try {
                final MediaType contentType = headers.contentType();
                if (!encodableContentTypePredicate.test(contentType)) {
                    return false;
                }
            } catch (IllegalArgumentException e) {
                // Don't know content type of response, don't encode.
                return false;
            }
        }

        // We switch to chunked encoding and compress the response if it's reasonably
        // large or the content length is unknown because the compression savings should
        // outweigh the chunked encoding overhead.
        long contentLength = headers.contentLength();
        if (contentLength == -1) {
            contentLength = Long.MAX_VALUE;
        }
        return contentLength >= minBytesToForceChunkedAndEncoding;
    }
A {@link FilteredStreamMessage} that applies HTTP encoding to {@link HttpObject}s as they are published.
core/src/main/java/com/linecorp/armeria/server/encoding/HttpEncodedResponse.java