Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 12, 2024 via pnpm

content-type 1.0.5

Create and parse HTTP Content-Type header
Package summary
Share
0
issues
1
license
1
MIT
Package created
8 Oct 2013
Version published
29 Jan 2023
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
content-type@1.0.5
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of content-type 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does content-type do?

The "content-type" is an npm package designed for creating and parsing the HTTP Content-Type header according to RFC 7231 protocols. It forms an integral part of web development, ensuring smooth and accurate data communication between client and server. It aids in identifying the type of content being exchanged, such as images, documents, or any other form of data.

How do you use content-type?

Leveraging the "content-type" package in your project is pretty simple and straightforward. After installing the package using npm with the command npm install content-type, you can import it to your JavaScript file using the require function.

To parse a Content-Type header from a string, use the contentType.parse() function like so:

var contentType = require('content-type');
var obj = contentType.parse('image/svg+xml; charset=utf-8');

It returns an object delineating the media type and parameters. For example, in this case, it will return { type: 'image/svg+xml', parameters: {charset: 'utf-8'} }.

You can also parse the Content-Type header directly from request or response objects:

var obj = contentType.parse(req);
var obj = contentType.parse(res);

Likewise, you can format a Content-Type header by providing an object to the contentType.format() function:

var str = contentType.format({ type: 'image/svg+xml', parameters: { charset: 'utf-8' } });

This will return a formatted string 'image/svg+xml; charset=utf-8'.

Where are the content-type docs?

The documentation for the "content-type" package is contained within the README provided in the package's GitHub repository, which is located at: git+https://github.com/jshttp/content-type.git. For more extensive information on each method and function, such as API details and examples, refer to the README file. It offers comprehensive explanations of each feature along with valuable example code to guide you through.