fix: recognize 'undefined' header value in ClientRequest
(#41615)
Co-authored-by: zowu <luke.wu@nokia-sbell.com>
This commit is contained in:
parent
08241669bc
commit
72c2b9e862
2 changed files with 37 additions and 18 deletions
|
@ -616,6 +616,25 @@ describe('net module (session)', () => {
|
|||
});
|
||||
}).to.throw('`partition` should be a string');
|
||||
});
|
||||
|
||||
it('should throw if given a header value that is empty(null/undefined)', () => {
|
||||
const emptyHeaderValues = [null, undefined];
|
||||
const errorMsg = '`value` required in setHeader("foo", value)';
|
||||
|
||||
for (const emptyValue of emptyHeaderValues) {
|
||||
expect(() => {
|
||||
net.request({
|
||||
url: 'https://foo',
|
||||
headers: { foo: emptyValue as any }
|
||||
} as any);
|
||||
}).to.throw(errorMsg);
|
||||
|
||||
const request = net.request({ url: 'https://foo' });
|
||||
expect(() => {
|
||||
request.setHeader('foo', emptyValue as any);
|
||||
}).to.throw(errorMsg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('net.fetch', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue