+htp #15910 import coding infrastructure from spray

Fixes #15910.

This still needs some tests but the implementation is itself is ready to be reviewed.
So aren't the usage from Decoder/Encoder tests enough, or do you want to test the failure cases?