httpclient: Rework Location header escape handling

Fixes #2187