I've noticed that nock is creating rawHeaders from the response headers object, which keys are lowercased. This is causing rawHeaders keys to also be lowercased, which I think is wrong because nock's rawHeaders may be getting different from the real response's rawHeaders. I believe rawHeaders case should be returned untouched.
This is the code responsible for it on lib/interceptor.js:62:
// We use lower-case headers throughout Nock.
headers = common.headersFieldNamesToLowerCase(headers);
_.defaults(this.options, this.scope.scopeOptions);
if (this.scope._defaultReplyHeaders) {
headers = headers || {};
headers = mixin(this.scope._defaultReplyHeaders, headers);
}
if (this.scope.date) {
headers = headers || {};
headers['date'] = this.scope.date.toUTCString();
}
if (headers !== undefined) {
this.headers = {};
this.rawHeaders = [];
// makes sure all keys in headers are in lower case
for (var key2 in headers) {
if (headers.hasOwnProperty(key2)) {
this.headers[key2.toLowerCase()] = headers[key2];
this.rawHeaders.push(key2);
this.rawHeaders.push(headers[key2]);
}
}
debug('reply.rawHeaders:', this.rawHeaders);
}
Why don't nock builds the headers object based on the rawHeaders array? Like that rawHeaders would remain untouched and headers could still have lowercased keys.
What do you think?
I've noticed that nock is creating
rawHeadersfrom the responseheadersobject, which keys are lowercased. This is causingrawHeaderskeys to also be lowercased, which I think is wrong because nock'srawHeadersmay be getting different from the real response'srawHeaders. I believerawHeaderscase should be returned untouched.This is the code responsible for it on
lib/interceptor.js:62:Why don't nock builds the
headersobject based on therawHeadersarray? Like thatrawHeaderswould remain untouched andheaderscould still have lowercased keys.What do you think?