Docker stats API returns partial JSON

Server Version: 1.11.1
Kernel Version: 3.10.0-327.13.1.el7.x86_64
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
OSType: linux
Architecture: x86_64

I have a Perl script that send stats request to socket /var/run/docker.sock: GET /containers/$id/stats?stream=0 HTTP/1.1

From time to time, I get bad response that starts with:
cp"},{“PrivatePort”:2181,“Type”:“tcp”}],“Labels”:{“com.docker.compose.config-hash”:“d1be80f19cd5099279c35d8221a17f8f041116572025218dbcc3d39b1d04c14f”,“com.docker.compose.container-number”:“1”,…

It doesn’t even have the proper HTTP response header