- Notifications
You must be signed in to change notification settings - Fork12
Manipulate the HTTP Vary header
License
jshttp/vary
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Manipulate the HTTP Vary header
This is aNode.js module available through thenpm registry. Installation is done using thenpm install
command:
$ npm install vary
varvary=require('vary')
Adds the given headerfield
to theVary
response header ofres
.This can be a string of a single field, a string of a validVary
header, or an array of multiple fields.
This will append the header if not already listed, otherwise leavesit listed in the current location.
// Append "Origin" to the Vary header of the responsevary(res,'Origin')
Adds the given headerfield
to theVary
response header stringheader
.This can be a string of a single field, a string of a validVary
header,or an array of multiple fields.
This will append the header if not already listed, otherwise leavesit listed in the current location. The new header string is returned.
// Get header string appending "Origin" to "Accept, User-Agent"vary.append('Accept, User-Agent','Origin')
varhttp=require('http')varvary=require('vary')http.createServer(functiononRequest(req,res){// about to user-agent sniffvary(res,'User-Agent')varua=req.headers['user-agent']||''varisMobile=/mobi|android|touch|mini/i.test(ua)// serve site, depending on isMobileres.setHeader('Content-Type','text/html')res.end('You are (probably) '+(isMobile ?'' :'not ')+'a mobile user')})
$ npmtest
About
Manipulate the HTTP Vary header
Topics
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors6
Uh oh!
There was an error while loading.Please reload this page.