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
{{ message }}
Repository navigation
response.writeHead() does not default statusMessage if it's undefined #32395
works as expected if statusMessage is omitted, supplying a default value.
However, if undefined is passed as a placeholder then it unexpectedly ignores the headers argument.
Why would I want this? Imagine a function like:
functionsend({ statusCode, statusMessage, headers, body }={statusCode: 404},res){returnnewPromise((resolve,reject)=>{res.writeHead(statusCode,statusMessage,headers).end(body).on('finish',resolve).on('error',reject)})}
You can see I depend on a single signature to work whether statusMessage is supplied or not. Otherwise, I have to:
So, actually, this title is inaccurate: response.writeHead() does not default statusMessage if it's undefined.
statusMessageis defaulted correctly by passing the value undefined. The problem is that then the headers, if passed, is ignored. So a more accurate title would be: response.writeHead() misbehaves when statusMessage is undefined
So, actually, this title is inaccurate: response.writeHead() does not default statusMessage if it's undefined.
statusMessageis defaulted correctly by passing the value undefined. The problem is that then the headers, if passed, is ignored. So a more accurate title would be: response.writeHead() misbehaves when statusMessage is undefined
Activity
himself65 commentedon Mar 21, 2020
I'm working on this.
himself65 commentedon Mar 21, 2020
Yes, this not a bug, just we have a different parameter processing
spazmodius commentedon Mar 21, 2020
So, actually, this title is inaccurate: response.writeHead() does not default
statusMessageif it's undefined.statusMessageis defaulted correctly by passing the valueundefined. The problem is that then theheaders, if passed, is ignored. So a more accurate title would be: response.writeHead() misbehaves whenstatusMessageis undefinedhimself65 commentedon Mar 21, 2020
yes, and i have fixed this in that PR
http: writeHead if statusmessage is undefined dont override headers
http: writeHead if statusmessage is undefined dont override headers
http: writeHead if statusmessage is undefined dont override headers
http: writeHead if statusmessage is undefined dont override headers
http: writeHead if statusmessage is undefined dont override headers