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-disposition 0.5.4

Create and parse Content-Disposition header
Package summary
Share
0
issues
1
license
2
MIT
Package created
19 Sep 2014
Version published
10 Dec 2021
Maintainers
1
Total deps
2
Direct deps
1
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
2 Packages, Including:
content-disposition@0.5.4
safe-buffer@5.2.1
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

1
All Dependencies CSV
β“˜ This is a list of content-disposition 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
safe-buffer5.2.19.74 kBMIT
prod

Visualizations

Frequently Asked Questions

What does content-disposition do?

Content-Dispostion is an npm package utilized for creating and parsing HTTP 'Content-Disposition' headers. It is particularly useful when you need to communicate information about the file being sent or received. This can include specifications such as whether the file is to be displayed inline in the browser, or presented as a file download.

How do you use content-disposition?

To use the Content-Disposition package, you first need to install it via npm using the command npm install content-disposition. Once installed, you can require this package in your JavaScript file with var contentDisposition = require('content-disposition').

You can create a 'Content-Disposition' header using the contentDisposition(filename, options) function, where filename is the name of the file you're working with, and options is an optional parameter specifying additional details. An example usage can be res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf')).

If you want to parse a 'Content-Disposition' header string, you can use the contentDisposition.parse(string) function. This function takes the header string as an input and automatically handles the decoding of any extended ("Unicode") parameters, returning them under the standard parameter name.

Here is an example of sending a file for download:

var contentDisposition = require('content-disposition')
var destroy = require('destroy')
var fs = require('fs')
var http = require('http')
var onFinished = require('on-finished')

var filePath = '/path/to/public/plans.pdf'

http.createServer(function onRequest (req, res) {
  // set headers
  res.setHeader('Content-Type', 'application/pdf')
  res.setHeader('Content-Disposition', contentDisposition(filePath))

  // send file
  var stream = fs.createReadStream(filePath)
  stream.pipe(res)
  onFinished(res, function () {
    destroy(stream)
  })
})

The 'destroy' and 'on-finished' modules are used to handle cleanup after the file is sent.

Where are the content-disposition docs?

The official documentation for the Content-Disposition package is contained within the README file in the GitHub repository (https://github.com/jshttp/content-disposition). It provides a comprehensive overview of the package's API, options, and examples of how you can use it. For more specific details or technicalities related to 'Content-Disposition' header, refer to the RFCs linked in the "References" section of the package's README.