我想通過node返回arraybuffer給客戶端,但是遇到了問題:server.js:res.write(new Buffer([0,1,2])); res.writeHead(200,{'Access-Control-Allow-Origin':'*','Access-Control-Allow-Method':'GET,POST','Content-Type':'application/octet-stream'}); res.end();客戶端代碼:var xhr = new XMLHttpRequest(); xhr.responseType = "arraybuffer"; xhr.open("post","http://localhost:8008/"); xhr.onload = function(data){ if(xhr.status === 200){ console.log('succuess'); var blo = new Blob(this.response); var reader = new FileReader(); reader.readAsBinaryString(blo); reader.onload = function(f){ console.log(this.result); } } }但是chrome控制臺并沒有打印結果,而是輸出錯誤:POST http://localhost:8008/ net::ERR_INVALID_CHUNKED_ENCODING請問這是怎么回事呢,謝謝aaa
nodejs返回arraybuffer給客戶端的問題
一只斗牛犬
2018-09-12 09:09:13