New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details → →
Socket
Book a DemoSign in
Socket

enforce-content-type

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enforce-content-type

Enforce Content-Type headers on request

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Enforce Content-Type middleware

npm version Build Status Coverage Status js-standard-style

This middleware enforces the Content-Type header of requests to be a specified value. If the header doesn't match that value, a HTTP status code 415 "Unsupported Media Type" is returned.

var enforceContentType = require('enforce-content-type')

app.use(enforceContentType({
  type: 'application/json'
}))

It is also possible to specify multiple acceptable content types:

app.use(enforceContentType({
  type: [
    'application/json',
    'multipart/form-data'
  ]
}))

Requests without a body are not enforced unless the force option is set to true:

app.use(enforceContentType({
  force: true,
  type: 'application/json'
}))

Keywords

http

FAQs

Package last updated on 17 May 2016

Did you know?

Socket

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.

Install

Related posts