Closed
Description
Is your feature request related to a problem? Please describe.
When working with vanilla node HTTP servers, I frequently make the mistake that res.setHeader
and (more often) res.writeHead
return this
, allowing a .end
to be appended. For example:
res.writeHead(201, headers).end(body);
This is an error, since writeHead
returns undefined
.
Describe the solution you'd like
I'd like to have res.setHeader
and res.writeHead
return this
to allow chaining. The same behaviour should be added to the HTTP/2 compatibility module too. I'm happy to put together a pull request if you are open to the change.
Describe alternatives you've considered
I sometimes define a helper function to do this, but it's clunky.