
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
http-accept
Advanced tools
Accept parses all accept header fields and sorts them according to the HTTP specification.
Parsed into req.accept.types.
Parsed into req.accept.charsets.
Parsed into req.accept.encodings.
Parsed into req.accept.languages.
Parsed into req.accept.ranges.
npm install http-accept
Just require 'http-accept' and throw it into a connect compatible middlware
stack.
connect = require 'connect'
http = require 'http'
accept = require 'http-accept'
app = connect()
app.use connect.logger 'dev'
app.use accept
app.use (req, res) ->
console.log req.accept
res.end()
app.listen 3000
A request from a browser on http://localhost:3000 would print out
{ types:
[ { type: 'text',
subtype: 'html',
params: {},
mediarange: 'text/html',
quality: 1 },
{ type: 'application',
subtype: 'xhtml+xml',
params: {},
mediarange: 'application/xhtml+xml',
quality: 1 },
{ type: 'application',
subtype: 'xml',
params: [Object],
mediarange: 'application/xml',
quality: 0.9 },
{ type: '*',
subtype: '*',
params: [Object],
mediarange: '*/*',
quality: 0.8 } ],
charsets: undefined,
encodings: [ 'gzip', 'deflate' ],
languages: [ 'de-de', 'de', 'en-us', 'en' ],
ranges: undefined }
For each header present in the request, there is also a getBestMatch method which will find the highest quality match amongst the supplied candidates.
encoding = (req.accept.encodings?.getBestMatch ["gzip", "deflate"]) ? "identity"
mediaType = req.accept.types?.getBestMatch ["text/html", "application/json" ,"application/xml"]
FAQs
Connect compatible middleware that parses HTTP Accept header fields
We found that http-accept demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.