setheaders
v0.4.0
Published
boilerplate for res.setHeader, protection from being overridden
Downloads
12,218
Readme
setheaders
boilerplate for res.setHeader, protection from being overridden and more!
Installation
Install through NPM
npm install setheaders
or
git clone git://github.com/hex7c0/setheaders.git
API
inside nodejs project, set pippo
as "X-Foo" header
var setHeader = require('setheaders');
setHeader(res, 'X-Foo', 'pippo');
there are different shortcuts, instead of setting correct argument
var setHeader = require('setheaders');
var setProctedHeader = setHeader.setProctedHeader; // protected = true
var setOverrideHeader = setHeader.setOverrideHeader; // override = true
var setWritableHeader = setHeader.setWritableHeader; // writable = true
setheaders(res, name, value [, protected [, override [, writable] ] ])
options
res
- Object response to client (default "required")name
- String header's name (default "required")value
- String header's value (default "required")[protected]
- true set protected header, from being overridden before they are written to response (default "false")[override]
- true check if I'm trying to override a header (default "false")[writable]
- true check if socket is writable, prevent write Error (default "false")
Examples
Take a look at my examples