+htp #15930 import RangeDirectives from spray

Based on a rebased version of #16183. So, just review the last commit. I will rebase once the other PR is merged.

Fixes #15930.

/cc @sirthias
Great comment explaining why this is done.