static HeaderGroup filterHopByHopHeaders(final HttpMessage message) {
        final Set<String> hopByHop = MessageSupport.hopByHopConnectionSpecific(message);
        final HeaderGroup headerGroup = new HeaderGroup();
        for (final Iterator<Header> it = message.headerIterator(); it.hasNext(); ) {
            final Header header = it.next();
            if (!hopByHop.contains(header.getName())) {
                headerGroup.addHeader(header);
            }
        }
        return headerGroup;
    }
This method should be provided by the core
httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheEntryFactory.java