default void close(AggregatedHttpResponse res) {
        boolean transferredContent = false;
        HttpData content = null;
        try {
            requireNonNull(res, "res");
            final ResponseHeaders headers = res.headers();
            content = res.content();
            if (!tryWrite(headers)) {
                return;
            }

            if (headers.status().isContentAlwaysEmpty()) {
                if (!content.isEmpty()) {
                    httpResponseUtilLogger.debug(
                            "Non-empty content found with an empty status: {}, content length: {}",
                            headers.status(), content.length());
                }
            } else if (!content.isEmpty()) {
                transferredContent = true;
                if (!tryWrite(content)) {
                    return;
                }
            }

            final HttpHeaders trailers = res.trailers();
            if (!trailers.isEmpty()) {
                @SuppressWarnings("CheckReturnValue")
                final boolean ignored = tryWrite(trailers);
            }
        } finally {
            close();
            if (!transferredContent && content != null) {
                content.close();
            }
        }
    }
Writes the specified HTTP response and closes the stream.
core/src/main/java/com/linecorp/armeria/common/HttpResponseWriter.java