ethanent / phin

Node HTTP client
MIT License
576 stars 33 forks source link

Exception when requesting a compressed stream #88

Open yetzt opened 1 year ago

yetzt commented 1 year ago

It appears, when stream: true and compression: true, centra delivers a gzip stream which does no contain a headers property, causing an exception in phin.js at res.headers.hasOwnProperty('location')

const phin = require("phin");

phin({
    url: "https://github.com/",
    stream: true,
    compression: true,
}).then(function(resp){
    console.log(resp);
}).catch(function(err){
    console.log(err.stack);
});
TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')
    at phin (.../node_modules/phin/lib/phin.js:60:18)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)