1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
# vary
[](https://www.npmjs.org/package/vary)
[](http://nodejs.org/download/)
[](https://travis-ci.org/jshttp/vary)
[](https://coveralls.io/r/jshttp/vary)
[](https://www.gittip.com/dougwilson/)
Manipulate the HTTP Vary header
## Install
```sh
$ npm install vary
```
## API
```js
var vary = require('vary')
```
### vary(res, field)
Adds the given header `field` to the `Vary` response header of `res`.
This can be a string of a single field, a string of a valid `Vary`
header, or an array of multiple fields.
This will append the header if not already listed, otherwise leaves
it listed in the current location.
```js
// Append "Origin" to the Vary header of the response
vary(res, 'Origin')
```
### vary.append(header, field)
Adds the given header `field` to the `Vary` response header string `header`.
This can be a string of a single field, a string of a valid `Vary` header,
or an array of multiple fields.
This will append the header if not already listed, otherwise leaves
it listed in the current location. The new header string is returned.
```js
// Get header string appending "Origin" to "Accept, User-Agent"
vary.append('Accept, User-Agent', 'Origin')
```
## Testing
```sh
$ npm test
```
## License
[MIT](LICENSE)
|