static void maskHeaders(
            HttpHeaders headers, Set<AsciiString> sensitiveHeaders,
            HeaderMaskingFunction maskingFunction,
            BiConsumer<AsciiString, List<String>> consumer) {
        for (AsciiString headerName : headers.names()) {
            List<String> values = headers.getAll(headerName);
            if (sensitiveHeaders.contains(headerName)) {
                // Mask the header values.
                if (values.size() == 1) {
                    final String masked = maskingFunction.mask(headerName, values.get(0));
                    if (masked == null) {
                        values = ImmutableList.of();
                    } else {
                        values = ImmutableList.of(masked);
                    }
                } else {
                    values = values.stream()
                                   .map(value -> maskingFunction.mask(headerName, value))
                                   .filter(Objects::nonNull)
                                   .collect(toImmutableList());
                }
            }
            if (!values.isEmpty()) {
                consumer.accept(headerName, values);
            }
        }
    }
A sanitizer that sanitizes {@link HttpHeaders} and returns {@link String}.
core/src/main/java/com/linecorp/armeria/common/logging/TextHeadersSanitizer.java