\href{https://npmjs.org/package/content-disposition}{\texttt{ }} \href{https://npmjs.org/package/content-disposition}{\texttt{ }} \href{https://nodejs.org/en/download}{\texttt{ }} \href{https://travis-ci.org/jshttp/content-disposition}{\texttt{ }} \href{https://coveralls.io/r/jshttp/content-disposition?branch=master}{\texttt{ }}

Create and parse HTTP {\ttfamily Content-\/\+Disposition} header\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6497}{}\doxysection{Installation}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6497}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install content-\/disposition }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6498}{}\doxysection{API}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6498}

\begin{DoxyCode}{0}
\DoxyCodeLine{var contentDisposition = require('content-\/disposition') }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6499}{}\doxysubsection{content\+Disposition(filename, options)}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6499}
Create an attachment {\ttfamily Content-\/\+Disposition} header value using the given file name, if supplied. The {\ttfamily filename} is optional and if no file name is desired, but you want to specify {\ttfamily options}, set {\ttfamily filename} to {\ttfamily undefined}.


\begin{DoxyCode}{0}
\DoxyCodeLine{res.setHeader('Content-\/Disposition', contentDisposition('∫ maths.pdf')) }

\end{DoxyCode}


{\bfseries{note}} HTTP headers are of the ISO-\/8859-\/1 character set. If you are writing this header through a means different from {\ttfamily set\+Header} in Node.\+js, you\textquotesingle{}ll want to specify the `\textquotesingle{}binary'\`{} encoding in Node.\+js.\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6500}{}\doxysubsubsection{Options}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6500}
{\ttfamily content\+Disposition} accepts these properties in the options object.\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6501}{}\doxyparagraph{fallback}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6501}
If the {\ttfamily 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 {\ttfamily true}.


\begin{DoxyItemize}
\item A string will specify the ISO-\/8859-\/1 file name to use in place of automatic generation.
\item {\ttfamily 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).
\item {\ttfamily true} will enable automatic generation if the file name is outside ISO-\/8859-\/1.
\end{DoxyItemize}

If the {\ttfamily filename} option is ISO-\/8859-\/1 and this option is specified and has a different value, then the {\ttfamily filename} option is encoded in the extended field and this set as the fallback field, even though they are both ISO-\/8859-\/1.\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6502}{}\doxyparagraph{type}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6502}
Specifies the disposition type, defaults to {\ttfamily \char`\"{}attachment\char`\"{}}. This can also be {\ttfamily \char`\"{}inline\char`\"{}}, or any other value (all values except inline are treated like {\ttfamily attachment}, but can convey additional information if both parties agree to it). The type is normalized to lower-\/case.\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6503}{}\doxysubsection{content\+Disposition.\+parse(string)}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6503}

\begin{DoxyCode}{0}
\DoxyCodeLine{var disposition = contentDisposition.parse('attachment; filename="{}EURO rates.txt"{}; filename*=UTF-\/8\(\backslash\)'\(\backslash\)'\%e2\%82\%ac\%20rates.txt') }

\end{DoxyCode}


Parse a {\ttfamily Content-\/\+Disposition} header string. This automatically handles extended (\char`\"{}\+Unicode\char`\"{}) 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 `\textquotesingle{}attachment; filename=\char`\"{}\+EURO rates.\+txt\char`\"{}; filename$\ast$=UTF-\/8\&rsquo;\textbackslash{}\textquotesingle{}e2\%82ac\%20rates.\+txt\textquotesingle{}\`{})\+:


\begin{DoxyItemize}
\item {\ttfamily type}\+: The disposition type (always lower case). Example\+: `\textquotesingle{}attachment'\`{}
\item {\ttfamily parameters}\+: An object of the parameters in the disposition (name of parameter always lower case and extended versions replace non-\/extended versions). Example\+: {\ttfamily \{filename\+: \char`\"{}€ rates.\+txt\char`\"{}\}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6504}{}\doxysection{Examples}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6504}
\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6505}{}\doxysubsection{Send a file for download}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6505}

\begin{DoxyCode}{0}
\DoxyCodeLine{var contentDisposition = require('content-\/disposition')}
\DoxyCodeLine{var destroy = require('destroy')}
\DoxyCodeLine{var fs = require('fs')}
\DoxyCodeLine{var http = require('http')}
\DoxyCodeLine{var onFinished = require('on-\/finished')}
\DoxyCodeLine{}
\DoxyCodeLine{var filePath = '/path/to/public/plans.pdf'}
\DoxyCodeLine{}
\DoxyCodeLine{http.createServer(function onRequest (req, res) \{}
\DoxyCodeLine{  // set headers}
\DoxyCodeLine{  res.setHeader('Content-\/Type', 'application/pdf')}
\DoxyCodeLine{  res.setHeader('Content-\/Disposition', contentDisposition(filePath))}
\DoxyCodeLine{}
\DoxyCodeLine{  // send file}
\DoxyCodeLine{  var stream = fs.createReadStream(filePath)}
\DoxyCodeLine{  stream.pipe(res)}
\DoxyCodeLine{  onFinished(res, function () \{}
\DoxyCodeLine{    destroy(stream)}
\DoxyCodeLine{  \})}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6506}{}\doxysection{Testing}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6506}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm test }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6507}{}\doxysection{References}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6507}

\begin{DoxyItemize}
\item \href{https://tools.ietf.org/html/rfc2616}{\texttt{ RFC 2616\+: Hypertext Transfer Protocol -- HTTP/1.\+1}}
\item \href{https://tools.ietf.org/html/rfc5987}{\texttt{ RFC 5987\+: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters}}
\item \href{https://tools.ietf.org/html/rfc6266}{\texttt{ RFC 6266\+: Use of the Content-\/\+Disposition Header Field in the Hypertext Transfer Protocol (HTTP)}}
\item \href{http://greenbytes.de/tech/tc2231/}{\texttt{ Test Cases for HTTP Content-\/\+Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_content_disposition_README_autotoc_md6508}{}\doxysection{License}\label{md_sfcode_node_modules_content_disposition_README_autotoc_md6508}
\mbox{[}MIT\mbox{]}(LICENSE) 