public static ResponseHeaders mergeResponseHeaders(ResponseHeaders headers,
                                                       HttpHeaders additionalHeaders,
                                                       HttpHeaders defaultHeaders,
                                                       boolean serverHeaderEnabled, boolean dateHeaderEnabled) {
        if (additionalHeaders.isEmpty() && defaultHeaders.isEmpty() &&
            !serverHeaderEnabled && !dateHeaderEnabled) {
            return headers;
        }

        final ResponseHeadersBuilder builder = headers.toBuilder();

        for (AsciiString name : additionalHeaders.names()) {
            if (!isPseudoHeader(name)) {
                builder.remove(name);
                additionalHeaders.forEachValue(name, value -> builder.add(name, value));
            }
        }

        for (AsciiString name : defaultHeaders.names()) {
            if (!isPseudoHeader(name) && !builder.contains(name)) {
                defaultHeaders.forEachValue(name, value -> builder.add(name, value));
            }
        }

        // Framework headers
        if (serverHeaderEnabled && !builder.contains(HttpHeaderNames.SERVER)) {
            builder.add(HttpHeaderNames.SERVER, ArmeriaHttpUtil.SERVER_HEADER);
        }
        if (dateHeaderEnabled && !builder.contains(HttpHeaderNames.DATE)) {
            builder.add(HttpHeaderNames.DATE, HttpTimestampSupplier.currentTime());
        }

        return builder.build();
    }
Merges the given {@link ResponseHeaders}. The headers have priority in the following order.
<pre>{@code
additional headers (highest priority) > headers > default headers > framework headers (lowest priority)
}</pre>
core/src/main/java/com/linecorp/armeria/internal/common/HttpHeadersUtil.java