Fix net module to accept non-string header values

This is required to be compatible with node.js http module.
This commit is contained in:
Thiago de Arruda 2017-03-30 13:24:40 -03:00
parent 57edc28b0d
commit b3cf00a19a
3 changed files with 49 additions and 5 deletions

View file

@ -246,7 +246,7 @@ class ClientRequest extends EventEmitter {
if (typeof name !== 'string') {
throw new TypeError('`name` should be a string in setHeader(name, value).')
}
if (value === undefined) {
if (value == null) {
throw new Error('`value` required in setHeader("' + name + '", value).')
}
if (!this.urlRequest.notStarted) {
@ -255,7 +255,7 @@ class ClientRequest extends EventEmitter {
const key = name.toLowerCase()
this.extraHeaders[key] = value
this.urlRequest.setExtraHeader(name, value)
this.urlRequest.setExtraHeader(name, value.toString())
}
getHeader (name) {