See https://github.com/bagder/curl/pull/60
Often times proxy servers add their own headers (like HTTP/1.0 200 Connection established) to responses on their way back to the client. The size of these headers was not taken into account when calculating CURLINFO_HEADER_SIZE before the change from this pull request.
The problem can be reproduced quite easily using the test program from https://gist.github.com/mj/5102778. In our case the proxy server at proxy:8080 was the default Squid that ships with Debian stable.
I'm working on fixing up the test suite to be able to test for this and verify both the bug and your fix.
Thanks, this has been merged into master now. I failed in making a proper test case for this so far, as it turned out a bit messier than I would have liked. I will still try to get a test or two done for this later on.
Case closed!