There's a helper method in slimmer to do this: https://github.com/alphagov/slimmer/blob/master/lib/slimmer/headers.rb#L38-L44