BUG Do not rely on broken curl header size calculation.

Header parsing now takes into account situations like a proxy or
redirections. Works around the curl issue.

Also fixes the issue when a redirected request would cause a double
amount of headers coming out of the parser - it would merrily process
anything that's in key:value format even if it was two distinct headers.
Merge pull request #2436 from mateusz/restfulservice-headers

BUG Do not rely on broken curl header size calculation.