This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

sweet

0.1.1 • Public • Published

Sweet: Setting HTTP Content-Disposition Headers

Getting the syntax for HTTP Content-Disposition headers to work well with browsers well is tricky, especially if you want the filename to contain non-ASCII characters.

Sweet is here to help.

It exposes one function - make_disposition - that returns a value suitable for use as a Content-Disposition header value.

For example:

var http = require('http');
var sweet = require('sweet');

// "my stuff" in Japanese
var cd_value = sweet.make_disposition(
  'attachment', '私のもの', 'my stuff'
);

http.createServer(function (req, res) {
  res.writeHead(200, {
    'Content-Type': 'text/plain',
    'Content-Disposition': cd_value
  });
  res.end('Hello World\n');
}).listen(1337, "127.0.0.1");

See RFC6266 for the spec and related details.

Note that Sweet is just for setting Content-Disposition in HTTP responses (e.g., for file downloads); it won't help with MIME multi-part messages, for example.

Contact

Mark Nottingham mnot@mnot.net

https://github.com/mnot/sweet

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Published

Version History

  • Version
    Downloads (Last 7 Days)
    • Published

Package Sidebar

Install

npm i sweet

Weekly Downloads

36

Version

0.1.1

License

none

Last publish

Collaborators

  • mnot