safe-set-header

1.0.0 • Public • Published

safe-set-header

🤯 make ServerResponse.setHeader idempotent for HttpServer

require('safe-set-header')();

Will not try to set headers after they were sent. For example, if a middleware has already sent relevant response headers

Example of errors that should not happen:

  • ERR_HTTP2_HEADERS_AFTER_RESPOND (Cannot specify additional headers after response initiated)
  • ERR_HTTP_HEADERS_SENT (Cannot set headers after they are sent to the client)

log cases where this happens

[optional] Pass in a log function. The log function will be called with an error object

require('safe-set-header')({log: console.log});

Package Sidebar

Install

npm i safe-set-header

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

1.9 kB

Total Files

3

Last publish

Collaborators

  • omrilotan