简体   繁体   English

NodeJS加密的HTTPS响应主体

[英]NodeJS Encrypted HTTPS Response Body

I'm creating a small icloud client using node, so that I can pull down some of my data and analyze it. 我正在使用节点创建一个小型icloud客户端,以便可以提取一些数据并进行分析。 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. 当我收到响应时,标头就很好了,并且我期望的会话cookie也在那里,但是应该为JSON的响应正文看起来已经加密了,甚至不是纯文本。 It's over SSL, but if the headers are readable, shouldn't the body be as well? 它是通过SSL进行的,但是如果标头是可读的,正文是否也应该如此? Is there a setting I'm missing or a bug in node, i'm using the latest, 0.8.1 是否有我缺少的设置或节点中的错误,我使用的是最新的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. 根据响应标头content-encoding: gzip ,响应未加密,只是经过压缩。 You can use Node's zlib module to decompress it on the fly. 您可以使用Node的zlib模块即时对其进行解压缩。 Here's an example using my blog's homepage as the endpoint (since my server responds with gzipped data when asked): 这是一个使用我的博客主页作为端点的示例(因为我的服务器在被询问时以gzip压缩的数据响应):

http = require('http');
zlib = require('zlib');
url = require('url');

var uri = url.parse("http://brandontilley.com/");
uri.headers = {'accept-encoding': 'gzip'};

var request = http.get(uri, function(res) {
  var buffers = [];
  res.pipe(zlib.createGunzip()).on('data', function(chunk) {
    buffers.push(chunk);
  }).on('end', function() {
    console.log(Buffer.concat(buffers).toString());
  });
});
request.end();

There are some more examples on the Node.js documentation for the zlib module . zlib模块Node.js文档中还有更多示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM