📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

content-type

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

content-type

Create and parse HTTP Content-Type header

1.0.5
latest
Source
npm
Version published
Weekly downloads
28M
-20.16%
Maintainers
1
Weekly downloads
 
Created

What is content-type?

The content-type npm package is used to create and parse HTTP Content-Type header according to RFC 7231. It allows you to parse content-type strings to objects and format content-type objects to strings.

What are content-type's main functionalities?

Parsing Content-Type

This feature allows you to parse a Content-Type string, returning an object with the media type and parameters like charset.

const contentType = require('content-type');
const parsed = contentType.parse('text/html; charset=utf-8');

Formatting Content-Type

This feature enables you to format an object representing a Content-Type into a string that can be used in HTTP headers.

const contentType = require('content-type');
const format = contentType.format({ type: 'text/html', parameters: { charset: 'utf-8' } });

Other packages similar to content-type

Keywords

content-type

FAQs

Package last updated on 29 Jan 2023

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