Changed the way parse_response splits the response into headers and body. One of the explode or array_pop would leave out some data. Now using substr it seems that the issue was resolved.