I somewhat recently had exactly the same problem (using winhhtp). I eventually redid much of the surrounding code with naked pointers and memcpy. But (I worked out later) the issue was not with string but with an implicit conversion that was occuring along the way, which truncated the final result at the first null character.