demo___customer_pitch-c4152739-a50b-4b5b-9d4d-0561461666d9.zip-extract/_dependencies/npm/content-disposition-0.5.4/README.md

Path
demo___customer_pitch-c4152739-a50b-4b5b-9d4d-0561461666d9.zip-extract/_dependencies/npm/content-disposition-0.5.4/README.md
Status
scanned
Type
file
Name
README.md
Extension
.md
Programming language

      
    
Mime type
text/plain
File type
UTF-8 Unicode text
Tag

      
    
Rootfs path

      
    
Size
5205 (5.1 KB)
MD5
cbd415ae5e4605f9ce13640c323d8aaf
SHA1
e1d109d584a63de2418adfd8fb59b298d0d9368e
SHA256
871c5ec648b67ad1a5791c6c4f95e5bb5df78ecc9aae0a3387e2a08e068c6968
SHA512

      
    
SHA1_git
3a0bb055949cdaed008f0f85e111624214213873
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
README.md | 5.1 KB |

# content-disposition [![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url] [![Node.js Version][node-version-image]][node-version-url] [![Build Status][github-actions-ci-image]][github-actions-ci-url] [![Test Coverage][coveralls-image]][coveralls-url] Create and parse HTTP `Content-Disposition` header ## Installation ```sh $ npm install content-disposition ``` ## API ```js var contentDisposition = require('content-disposition') ``` ### contentDisposition(filename, options) Create an attachment `Content-Disposition` header value using the given file name, if supplied. The `filename` is optional and if no file name is desired, but you want to specify `options`, set `filename` to `undefined`. ```js res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf')) ``` **note** HTTP headers are of the ISO-8859-1 character set. If you are writing this header through a means different from `setHeader` in Node.js, you'll want to specify the `'binary'` encoding in Node.js. #### Options `contentDisposition` accepts these properties in the options object. ##### fallback If the `filename` option is outside ISO-8859-1, then the file name is actually stored in a supplemental field for clients that support Unicode file names and a ISO-8859-1 version of the file name is automatically generated. This specifies the ISO-8859-1 file name to override the automatic generation or disables the generation all together, defaults to `true`. - A string will specify the ISO-8859-1 file name to use in place of automatic generation. - `false` will disable including a ISO-8859-1 file name and only include the Unicode version (unless the file name is already ISO-8859-1). - `true` will enable automatic generation if the file name is outside ISO-8859-1. If the `filename` option is ISO-8859-1 and this option is specified and has a different value, then the `filename` option is encoded in the extended field and this set as the fallback field, even though they are both ISO-8859-1. ##### type Specifies the disposition type, defaults to `"attachment"`. This can also be `"inline"`, or any other value (all values except inline are treated like `attachment`, but can convey additional information if both parties agree to it). The type is normalized to lower-case. ### contentDisposition.parse(string) ```js var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt') ``` Parse a `Content-Disposition` header string. This automatically handles extended ("Unicode") parameters by decoding them and providing them under the standard parameter name. This will return an object with the following properties (examples are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'`): - `type`: The disposition type (always lower case). Example: `'attachment'` - `parameters`: An object of the parameters in the disposition (name of parameter always lower case and extended versions replace non-extended versions). Example: `{filename: "€ rates.txt"}` ## Examples ### Send a file for download ```js 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) }) }) ``` ## Testing ```sh $ npm test ``` ## References - [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1][rfc-2616] - [RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters][rfc-5987] - [RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)][rfc-6266] - [Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987][tc-2231] [rfc-2616]: https://tools.ietf.org/html/rfc2616 [rfc-5987]: https://tools.ietf.org/html/rfc5987 [rfc-6266]: https://tools.ietf.org/html/rfc6266 [tc-2231]: http://greenbytes.de/tech/tc2231/ ## License [MIT](LICENSE) [npm-image]: https://img.shields.io/npm/v/content-disposition.svg [npm-url]: https://npmjs.org/package/content-disposition [node-version-image]: https://img.shields.io/node/v/content-disposition.svg [node-version-url]: https://nodejs.org/en/download [coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg [coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master [downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg [downloads-url]: https://npmjs.org/package/content-disposition [github-actions-ci-image]: https://img.shields.io/github/workflow/status/jshttp/content-disposition/ci/master?label=ci [github-actions-ci-url]: https://github.com/jshttp/content-disposition?query=workflow%3Aci
Detected license expression
mit
Detected license expression (SPDX)
MIT
Percentage of license text
0.41
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
mit-bdcba66f-6e80-f7bd-7994-748183fe5693 mit MIT
URL Start line End line
https://tools.ietf.org/html/rfc2616 124 124
https://tools.ietf.org/html/rfc5987 125 125
https://tools.ietf.org/html/rfc6266 126 126
http://greenbytes.de/tech/tc2231/ 127 127
https://img.shields.io/npm/v/content-disposition.svg 133 133
https://npmjs.org/package/content-disposition 134 134
https://img.shields.io/node/v/content-disposition.svg 135 135
https://nodejs.org/en/download 136 136
https://img.shields.io/coveralls/jshttp/content-disposition.svg 137 137
https://coveralls.io/r/jshttp/content-disposition?branch=master 138 138
https://img.shields.io/npm/dm/content-disposition.svg 139 139
https://img.shields.io/github/workflow/status/jshttp/content-disposition/ci/master?label=ci 141 141
https://github.com/jshttp/content-disposition?query=workflow:ci 142 142
Package URL License Primary language
pkg:npm/content-disposition@0.5.4 mit JavaScript
pkg:npm/acme-demo-app@1.0.0 JavaScript