You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We get different response objects based on the server's decision (compression/no compression). This is not very clear to anyone who needs to debug this.
The PassThrough stream has some own properties hanging from it (e.g. the headers getter), but the IncomingMessage response only inherits those from the IncomingMessage prototype. This means that { ...passThroughResponse }.headers exists, but { ...incomingMessageResponse }.headers is undefined. See 1. - this only depends on the server's decision, so it gets really confusing.
Minimal reproduction scenario:
// compresedResponse is a PassThrough stream (because of the decompression)constcompressedResponse=awaitgot('http://httpbin.org/gzip');const{headers: gzipHeaders}={ ...compressedResponse};// uncompressedResponse is an IncomingMessage (native Node.js response object)constuncompressedResponse=awaitgot('http://httpbin.org/html');const{headers: htmlHeaders}={ ...uncompressedResponse};console.log(`gzip response headers:`,gzipHeaders);console.log(`html response headers:`,htmlHeaders);
A response with enabled decompression is a prototype-child of a
PassThrough
stream, but without the decompression, it's Node'sIncomingMessage
.This happens here in
got
:got/source/core/index.ts
Line 655 in 3034c2f
Why is it a problem
PassThrough
stream has some own properties hanging from it (e.g. theheaders
getter), but theIncomingMessage
response only inherits those from theIncomingMessage
prototype. This means that{ ...passThroughResponse }.headers
exists, but{ ...incomingMessageResponse }.headers
is undefined. See 1. - this only depends on the server's decision, so it gets really confusing.Minimal reproduction scenario:
results in
The text was updated successfully, but these errors were encountered: