setheaders

boilerplate for res.setHeader, protection from being overridden

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
setheaders
140.4.06 years ago10 years agoMinified + gzip package size for setheaders in KB

Readme

NPM version Linux Status Windows Status Dependency Status Coveralls
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

License Apache2