I’m creating a small icloud client using node, so that I can pull down some of my data and analyze it. I’m currently scripting the login sequence. When I receive a response the headers are fine, and the session cookies i expect are there, but the response body which should be JSON looks encrypted, it’s not even plain text. It’s over SSL, but if the headers are readable, shouldn’t the body be as well? Is there a setting I’m missing or a bug in node, i’m using the latest, 0.8.1
{ date: 'Sat, 07 Jul 2012 14:51:56 GMT',
'x-apple-request-uuid': '............',
'x-responding-instance': '...........',
'cache-control': 'no-cache, no-store, private',
'access-control-allow-origin': 'https://www.icloud.com',
'access-control-allow-credentials': 'true',
'set-cookie': [........],
'content-type': 'application/json; charset=UTF-8',
'content-encoding': 'gzip',
'content-length': '126' }
���������VJ-*�/R�R
K��LI,IUJ-,M-.Q��U��,.��KW��u�q�
wur
��
��v�SH����LU�Q��+.I�KN�bhldijiaaf/.MNN-.V�JK�)N��$���l���
According to the response header
content-encoding: gzip, the response isn’t encrypted, it’s just compressed. You can use Node’szlibmodule to decompress it on the fly. Here’s an example using my blog’s homepage as the endpoint (since my server responds with gzipped data when asked):There are some more examples on the Node.js documentation for the zlib module.