+htp #15910 import + improve coding infrastructure from spray
Merge pull request #15984 from spray/w/15910-encoding-infrastructure

+htp #15910 import coding infrastructure from spray