即使响应头表示utf-8编码,服务器也会回复错误的编码(垃圾)

时间:2013-12-23 10:53:20

标签: node.js utf-8 soundcloud

请求标题:

{
    accept: 'application/json, text/javascript, */*; q=0.01',
    'accept-encoding': 'gzip,deflate,sdch',
    'accept-language': 'en-US,en;q=0.8',
    'cache-control': 'max-age=0',
    connection: 'keep-alive',
    Origin: 'https://soundcloud.com',
    Host: 'api.soundcloud.com',
    Referer: 'https://soundcloud.com/indigo919_fm/indigo-hotmix-with-dj-ivan-40'
}

响应标题:

{
    'content-encoding': 'gzip',
    'accept-ranges': 'bytes',
    'access-control-allow-headers': 'Accept, Authorization, Content-Type, Origin',
    'access-control-allow-methods': 'GET, PUT, POST, DELETE',
    'access-control-allow-origin': '*',
    'access-control-expose-headers': 'Date',
    'cache-control': 'max-age=600, public',
    'content-type': 'application/json; charset=utf-8',
    date: 'Mon, 23 Dec 2013 10:36:18 GMT',
    etag: '"68e2f3aed8a581235dc4494f68beef0d"',
    'last-modified': 'Mon, 23 Dec 2013 10:31:23 GMT',
    server: 'ECS (sin/47B8)',
    vary: 'Accept-Encoding',
    via: '1.1 varnish',
    'x-cache': 'HIT',
    'x-cacheable': 'YES',
    'x-runtime': '31',
    'x-varnish': '1382808179',
    'content-length': '1734'
}

服务器回复一些不可读的内容。图片中的网址是,

https://api.soundcloud.com/tracks/123974278?client_id=b45b1aa10f1ac2941910a7f0d10f8e28&app_version=5367f3cb

我在这里做错了什么?将相同的标头发送到网址时,

https://api.soundcloud.com/resolve?url=https://soundcloud.com/indigo919_fm/indigo-hotmix-with-dj-ivan-40&_status_code_map%5B302%5D=200&_status_format=json&client_id=b45b1aa10f1ac2941910a7f0d10f8e28&app_version=5367f3cb

服务器回复正确的JSON数据。

这在浏览器上执行时效果很好。我试图使用Node.js实现相同的目标。它与压缩有关吗?

0 个答案:

没有答案