为什么fetch不能获得 content-disposition 信息

870 阅读1分钟

当以流下载文件时,header有content-disposition字段。

content-disposition: attachment; filename="hello.zip"; 
content-length: 1000
content-type: application/octet-stream 

但是

fetch("http://IP/FILE").then(function(resp) {
  resp.headers.forEach(function(val, key) { console.log(key + ' -> ' + val); });
})

却不能取到headers中的content-disposition字段。

在问答网站中找到了答案,原来,跨域的时候,只能得到headers中的以下几种属性。

cors.png