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

An HTTP content negotiator for Node.\+js\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17982}{}\doxysection{Installation}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17982}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install negotiator }

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

\begin{DoxyCode}{0}
\DoxyCodeLine{var Negotiator = require('negotiator') }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17984}{}\doxysubsection{Accept Negotiation}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17984}

\begin{DoxyCode}{0}
\DoxyCodeLine{availableMediaTypes = ['text/html', 'text/plain', 'application/json']}
\DoxyCodeLine{}
\DoxyCodeLine{// The negotiator constructor receives a request object}
\DoxyCodeLine{negotiator = new Negotiator(request)}
\DoxyCodeLine{}
\DoxyCodeLine{// Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8'}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.mediaTypes()}
\DoxyCodeLine{// -\/> ['text/html', 'image/jpeg', 'application/*']}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.mediaTypes(availableMediaTypes)}
\DoxyCodeLine{// -\/> ['text/html', 'application/json']}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.mediaType(availableMediaTypes)}
\DoxyCodeLine{// -\/> 'text/html' }

\end{DoxyCode}


You can check a working example at {\ttfamily examples/accept.\+js}.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17985}{}\doxysubsubsection{Methods}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17985}
\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17986}{}\doxyparagraph{media\+Type()}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17986}
Returns the most preferred media type from the client.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17987}{}\doxyparagraph{media\+Type(available\+Media\+Type)}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17987}
Returns the most preferred media type from a list of available media types.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17988}{}\doxyparagraph{media\+Types()}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17988}
Returns an array of preferred media types ordered by the client preference.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17989}{}\doxyparagraph{media\+Types(available\+Media\+Types)}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17989}
Returns an array of preferred media types ordered by priority from a list of available media types.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17990}{}\doxysubsection{Accept-\/\+Language Negotiation}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17990}

\begin{DoxyCode}{0}
\DoxyCodeLine{negotiator = new Negotiator(request)}
\DoxyCodeLine{}
\DoxyCodeLine{availableLanguages = ['en', 'es', 'fr']}
\DoxyCodeLine{}
\DoxyCodeLine{// Let's say Accept-\/Language header is 'en;q=0.8, es, pt'}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.languages()}
\DoxyCodeLine{// -\/> ['es', 'pt', 'en']}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.languages(availableLanguages)}
\DoxyCodeLine{// -\/> ['es', 'en']}
\DoxyCodeLine{}
\DoxyCodeLine{language = negotiator.language(availableLanguages)}
\DoxyCodeLine{// -\/> 'es' }

\end{DoxyCode}


You can check a working example at {\ttfamily examples/language.\+js}.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17991}{}\doxysubsubsection{Methods}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17991}
\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17992}{}\doxyparagraph{language()}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17992}
Returns the most preferred language from the client.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17993}{}\doxyparagraph{language(available\+Languages)}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17993}
Returns the most preferred language from a list of available languages.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17994}{}\doxyparagraph{languages()}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17994}
Returns an array of preferred languages ordered by the client preference.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17995}{}\doxyparagraph{languages(available\+Languages)}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17995}
Returns an array of preferred languages ordered by priority from a list of available languages.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17996}{}\doxysubsection{Accept-\/\+Charset Negotiation}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17996}

\begin{DoxyCode}{0}
\DoxyCodeLine{availableCharsets = ['utf-\/8', 'iso-\/8859-\/1', 'iso-\/8859-\/5']}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator = new Negotiator(request)}
\DoxyCodeLine{}
\DoxyCodeLine{// Let's say Accept-\/Charset header is 'utf-\/8, iso-\/8859-\/1;q=0.8, utf-\/7;q=0.2'}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.charsets()}
\DoxyCodeLine{// -\/> ['utf-\/8', 'iso-\/8859-\/1', 'utf-\/7']}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.charsets(availableCharsets)}
\DoxyCodeLine{// -\/> ['utf-\/8', 'iso-\/8859-\/1']}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.charset(availableCharsets)}
\DoxyCodeLine{// -\/> 'utf-\/8' }

\end{DoxyCode}


You can check a working example at {\ttfamily examples/charset.\+js}.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17997}{}\doxysubsubsection{Methods}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17997}
\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17998}{}\doxyparagraph{charset()}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17998}
Returns the most preferred charset from the client.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md17999}{}\doxyparagraph{charset(available\+Charsets)}\label{md_sfcode_node_modules_negotiator_README_autotoc_md17999}
Returns the most preferred charset from a list of available charsets.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18000}{}\doxyparagraph{charsets()}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18000}
Returns an array of preferred charsets ordered by the client preference.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18001}{}\doxyparagraph{charsets(available\+Charsets)}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18001}
Returns an array of preferred charsets ordered by priority from a list of available charsets.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18002}{}\doxysubsection{Accept-\/\+Encoding Negotiation}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18002}

\begin{DoxyCode}{0}
\DoxyCodeLine{availableEncodings = ['identity', 'gzip']}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator = new Negotiator(request)}
\DoxyCodeLine{}
\DoxyCodeLine{// Let's say Accept-\/Encoding header is 'gzip, compress;q=0.2, identity;q=0.5'}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.encodings()}
\DoxyCodeLine{// -\/> ['gzip', 'identity', 'compress']}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.encodings(availableEncodings)}
\DoxyCodeLine{// -\/> ['gzip', 'identity']}
\DoxyCodeLine{}
\DoxyCodeLine{negotiator.encoding(availableEncodings)}
\DoxyCodeLine{// -\/> 'gzip' }

\end{DoxyCode}


You can check a working example at {\ttfamily examples/encoding.\+js}.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18003}{}\doxysubsubsection{Methods}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18003}
\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18004}{}\doxyparagraph{encoding()}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18004}
Returns the most preferred encoding from the client.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18005}{}\doxyparagraph{encoding(available\+Encodings)}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18005}
Returns the most preferred encoding from a list of available encodings.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18006}{}\doxyparagraph{encodings()}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18006}
Returns an array of preferred encodings ordered by the client preference.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18007}{}\doxyparagraph{encodings(available\+Encodings)}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18007}
Returns an array of preferred encodings ordered by priority from a list of available encodings.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18008}{}\doxysection{See Also}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18008}
The \href{https://npmjs.org/package/accepts\#readme}{\texttt{ accepts}} module builds on this module and provides an alternative interface, mime type validation, and more.\hypertarget{md_sfcode_node_modules_negotiator_README_autotoc_md18009}{}\doxysection{License}\label{md_sfcode_node_modules_negotiator_README_autotoc_md18009}
\mbox{[}MIT\mbox{]}(LICENSE) 