\href{https://github.com/zkat/make-fetch-happen}{\texttt{ {\ttfamily make-\/fetch-\/happen}}} is a Node.\+js library that wraps \href{https://github.com/npm/node-fetch-npm}{\texttt{ {\ttfamily node-\/fetch-\/npm}}} with additional features \href{https://github.com/bitinn/node-fetch}{\texttt{ {\ttfamily node-\/fetch}}} doesn\textquotesingle{}t intend to include, including HTTP Cache support, request pooling, proxies, retries, \href{\#features}{\texttt{ and more}}!\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16940}{}\doxysection{Install}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16940}
{\ttfamily \$ npm install -\/-\/save make-\/fetch-\/happen}\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16941}{}\doxysection{Table of Contents}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16941}

\begin{DoxyItemize}
\item \href{\#example}{\texttt{ Example}}
\item \href{\#features}{\texttt{ Features}}
\item \href{\#contributing}{\texttt{ Contributing}}
\item \href{\#api}{\texttt{ API}}
\begin{DoxyItemize}
\item \href{\#fetch}{\texttt{ {\ttfamily fetch}}}
\item \href{\#fetch-defaults}{\texttt{ {\ttfamily fetch.\+defaults}}}
\item \href{\#node-fetch-options}{\texttt{ {\ttfamily node-\/fetch} options}}
\item \href{\#extra-options}{\texttt{ {\ttfamily make-\/fetch-\/happen} options}}
\begin{DoxyItemize}
\item \href{\#opts-cache-manager}{\texttt{ {\ttfamily opts.\+cache\+Manager}}}
\item \href{\#opts-cache}{\texttt{ {\ttfamily opts.\+cache}}}
\item \href{\#opts-proxy}{\texttt{ {\ttfamily opts.\+proxy}}}
\item \href{\#opts-no-proxy}{\texttt{ {\ttfamily opts.\+no\+Proxy}}}
\item \href{\#https-opts}{\texttt{ {\ttfamily opts.\+ca, opts.\+cert, opts.\+key}}}
\item \href{\#opts-max-sockets}{\texttt{ {\ttfamily opts.\+max\+Sockets}}}
\item \href{\#opts-retry}{\texttt{ {\ttfamily opts.\+retry}}}
\item \href{\#opts-onretry}{\texttt{ {\ttfamily opts.\+on\+Retry}}}
\item \href{\#opts-integrity}{\texttt{ {\ttfamily opts.\+integrity}}}
\end{DoxyItemize}
\end{DoxyItemize}
\item \href{\#wow}{\texttt{ Message From Our Sponsors}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16942}{}\doxysubsection{Example}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16942}

\begin{DoxyCode}{0}
\DoxyCodeLine{const fetch = require('make-\/fetch-\/happen').defaults(\{}
\DoxyCodeLine{  cacheManager: './my-\/cache' // path where cache will be written (and read)}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{fetch('https://registry.npmjs.org/make-\/fetch-\/happen').then(res => \{}
\DoxyCodeLine{  return res.json() // download the body as JSON}
\DoxyCodeLine{\}).then(body => \{}
\DoxyCodeLine{  console.log(`got \$\{body.name\} from web`)}
\DoxyCodeLine{  return fetch('https://registry.npmjs.org/make-\/fetch-\/happen', \{}
\DoxyCodeLine{    cache: 'no-\/cache' // forces a conditional request}
\DoxyCodeLine{  \})}
\DoxyCodeLine{\}).then(res => \{}
\DoxyCodeLine{  console.log(res.status) // 304! cache validated!}
\DoxyCodeLine{  return res.json().then(body => \{}
\DoxyCodeLine{    console.log(`got \$\{body.name\} from cache`)}
\DoxyCodeLine{  \})}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16943}{}\doxysubsection{Features}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16943}

\begin{DoxyItemize}
\item Builds around \href{https://npm.im/node-fetch}{\texttt{ {\ttfamily node-\/fetch}}} for the core \href{https://fetch.spec.whatwg.org}{\texttt{ {\ttfamily fetch} API}} implementation
\item Request pooling out of the box
\item Quite fast, really
\item Automatic HTTP-\/semantics-\/aware request retries
\item Cache-\/fallback automatic \char`\"{}offline mode\char`\"{}
\item Proxy support (http, https, socks, socks4, socks5)
\item Built-\/in request caching following full HTTP caching rules ({\ttfamily Cache-\/\+Control}, {\ttfamily ETag}, {\ttfamily 304}s, cache fallback on error, etc).
\item Customize cache storage with any \href{https://developer.mozilla.org/en-US/docs/Web/API/Cache}{\texttt{ Cache API}}-\/compliant {\ttfamily Cache} instance. Cache to Redis!
\item Node.\+js Stream support
\item Transparent gzip and deflate support
\item \href{https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity}{\texttt{ Subresource Integrity}} support
\item Literally punches nazis
\item (PENDING) Range request caching and resuming
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16944}{}\doxysubsection{Contributing}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16944}
The make-\/fetch-\/happen team enthusiastically welcomes contributions and project participation! There\textquotesingle{}s a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don\textquotesingle{}t hesitate to jump in if you\textquotesingle{}d like to, or even ask us questions if something isn\textquotesingle{}t clear.

All participants and maintainers in this project are expected to follow Code of Conduct, and just generally be excellent to each other.

Please refer to the \mbox{\hyperlink{md_sfcode_node_modules_make_fetch_happen_CHANGELOG}{Changelog}} for project history details, too.

Happy hacking!\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16945}{}\doxysubsection{API}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16945}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16946}{}\doxysubsubsection{$<$a name=\char`\"{}fetch\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ fetch(uri\+Or\+Request, \mbox{[}opts\mbox{]}) -\/$>$ Promise$<$\+Response$>$$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16946}
This function implements most of the \href{https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch}{\texttt{ {\ttfamily fetch} API}}\+: given a {\ttfamily uri} string or a {\ttfamily Request} instance, it will fire off an http request and return a Promise containing the relevant response.

If {\ttfamily opts} is provided, the \href{\#node-fetch-options}{\texttt{ {\ttfamily node-\/fetch}-\/specific options}} will be passed to that library. There are also \href{\#extra-options}{\texttt{ additional options}} specific to make-\/fetch-\/happen that add various features, such as HTTP caching, integrity verification, proxy support, and more.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16947}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16947}

\begin{DoxyCode}{0}
\DoxyCodeLine{fetch('https://google.com').then(res => res.buffer()) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16948}{}\doxysubsubsection{$<$a name=\char`\"{}fetch-\/defaults\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ fetch.\+defaults(\mbox{[}default\+Url\mbox{]}, \mbox{[}default\+Opts\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16948}
Returns a new {\ttfamily fetch} function that will call {\ttfamily make-\/fetch-\/happen} using {\ttfamily default\+Url} and {\ttfamily default\+Opts} as default values to any calls.

A defaulted {\ttfamily fetch} will also have a {\ttfamily .defaults()} method, so they can be chained.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16949}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16949}

\begin{DoxyCode}{0}
\DoxyCodeLine{const fetch = require('make-\/fetch-\/happen').defaults(\{}
\DoxyCodeLine{  cacheManager: './my-\/local-\/cache'}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{fetch('https://registry.npmjs.org/make-\/fetch-\/happen') // will always use the cache }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16950}{}\doxysubsubsection{$<$a name=\char`\"{}node-\/fetch-\/options\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ node-\/fetch options$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16950}
The following options for {\ttfamily node-\/fetch} are used as-\/is\+:


\begin{DoxyItemize}
\item method
\item body
\item redirect
\item follow
\item timeout
\item compress
\item size
\end{DoxyItemize}

These other options are modified or augmented by make-\/fetch-\/happen\+:


\begin{DoxyItemize}
\item headers -\/ Default {\ttfamily User-\/\+Agent} set to make-\/fetch happen. {\ttfamily Connection} is set to {\ttfamily keep-\/alive} or {\ttfamily close} automatically depending on {\ttfamily opts.\+agent}.
\item agent
\begin{DoxyItemize}
\item If agent is null, an http or https Agent will be automatically used. By default, these will be {\ttfamily http.\+global\+Agent} and {\ttfamily https.\+global\+Agent}.
\item If \href{\#opts-proxy}{\texttt{ {\ttfamily opts.\+proxy}}} is provided and {\ttfamily opts.\+agent} is null, the agent will be set to an appropriate proxy-\/handling agent.
\item If {\ttfamily opts.\+agent} is an object, it will be used as the request-\/pooling agent argument for this request.
\item If {\ttfamily opts.\+agent} is {\ttfamily false}, it will be passed as-\/is to the underlying request library. This causes a new Agent to be spawned for every request.
\end{DoxyItemize}
\end{DoxyItemize}

For more details, see \href{https://github.com/bitinn/node-fetch\#options}{\texttt{ the documentation for {\ttfamily node-\/fetch} itself}}.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16951}{}\doxysubsubsection{$<$a name=\char`\"{}extra-\/options\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ make-\/fetch-\/happen options$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16951}
make-\/fetch-\/happen augments the {\ttfamily node-\/fetch} API with additional features available through extra options. The following extra options are available\+:


\begin{DoxyItemize}
\item \href{\#opts-cache-manager}{\texttt{ {\ttfamily opts.\+cache\+Manager}}} -\/ Cache target to read/write
\item \href{\#opts-cache}{\texttt{ {\ttfamily opts.\+cache}}} -\/ {\ttfamily fetch} cache mode. Controls cache {\itshape behavior}.
\item \href{\#opts-proxy}{\texttt{ {\ttfamily opts.\+proxy}}} -\/ Proxy agent
\item \href{\#opts-no-proxy}{\texttt{ {\ttfamily opts.\+no\+Proxy}}} -\/ Domain segments to disable proxying for.
\item \href{\#https-opts}{\texttt{ {\ttfamily opts.\+ca, opts.\+cert, opts.\+key, opts.\+strict\+SSL}}}
\item \href{\#opts-local-address}{\texttt{ {\ttfamily opts.\+local\+Address}}}
\item \href{\#opts-max-sockets}{\texttt{ {\ttfamily opts.\+max\+Sockets}}}
\item \href{\#opts-retry}{\texttt{ {\ttfamily opts.\+retry}}} -\/ Request retry settings
\item \href{\#opts-onretry}{\texttt{ {\ttfamily opts.\+on\+Retry}}} -\/ a function called whenever a retry is attempted
\item \href{\#opts-integrity}{\texttt{ {\ttfamily opts.\+integrity}}} -\/ \href{https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity}{\texttt{ Subresource Integrity}} metadata.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16952}{}\doxysubsubsection{$<$a name=\char`\"{}opts-\/cache-\/manager\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+cache\+Manager$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16952}
Either a {\ttfamily String} or a {\ttfamily Cache}. If the former, it will be assumed to be a {\ttfamily Path} to be used as the cache root for \href{https://npm.im/cacache}{\texttt{ {\ttfamily cacache}}}.

If an object is provided, it will be assumed to be a compliant \href{https://developer.mozilla.org/en-US/docs/Web/API/Cache}{\texttt{ {\ttfamily Cache} instance}}. Only {\ttfamily Cache.\+match()}, {\ttfamily Cache.\+put()}, and {\ttfamily Cache.\+delete()} are required. Options objects will not be passed in to {\ttfamily match()} or {\ttfamily delete()}.

By implementing this API, you can customize the storage backend for make-\/fetch-\/happen itself -- for example, you could implement a cache that uses {\ttfamily redis} for caching, or simply keeps everything in memory. Most of the caching logic exists entirely on the make-\/fetch-\/happen side, so the only thing you need to worry about is reading, writing, and deleting, as well as making sure {\ttfamily fetch.\+Response} objects are what gets returned.

You can refer to {\ttfamily cache.\+js} in the make-\/fetch-\/happen source code for a reference implementation.

{\bfseries{NOTE}}\+: Requests will not be cached unless their response bodies are consumed. You will need to use one of the {\ttfamily res.\+json()}, {\ttfamily res.\+buffer()}, etc methods on the response, or drain the {\ttfamily res.\+body} stream, in order for it to be written.

The default cache manager also adds the following headers to cached responses\+:


\begin{DoxyItemize}
\item {\ttfamily X-\/\+Local-\/\+Cache}\+: Path to the cache the content was found in
\item {\ttfamily X-\/\+Local-\/\+Cache-\/\+Key}\+: Unique cache entry key for this response
\item {\ttfamily X-\/\+Local-\/\+Cache-\/\+Hash}\+: Specific integrity hash for the cached entry
\item {\ttfamily X-\/\+Local-\/\+Cache-\/\+Time}\+: UTCString of the cache insertion time for the entry
\end{DoxyItemize}

Using \href{https://npm.im/cacache}{\texttt{ {\ttfamily cacache}}}, a call like this may be used to manually fetch the cached entry\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const h = response.headers}
\DoxyCodeLine{cacache.get(h.get('x-\/local-\/cache'), h.get('x-\/local-\/cache-\/key'))}
\DoxyCodeLine{}
\DoxyCodeLine{// grab content only, directly:}
\DoxyCodeLine{cacache.get.byDigest(h.get('x-\/local-\/cache'), h.get('x-\/local-\/cache-\/hash')) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16953}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16953}

\begin{DoxyCode}{0}
\DoxyCodeLine{fetch('https://registry.npmjs.org/make-\/fetch-\/happen', \{}
\DoxyCodeLine{  cacheManager: './my-\/local-\/cache'}
\DoxyCodeLine{\}) // -\/> 200-\/level response will be written to disk}
\DoxyCodeLine{}
\DoxyCodeLine{fetch('https://npm.im/cacache', \{}
\DoxyCodeLine{  cacheManager: new MyCustomRedisCache(process.env.PORT)}
\DoxyCodeLine{\}) // -\/> 200-\/level response will be written to redis }

\end{DoxyCode}


A possible (minimal) implementation for {\ttfamily My\+Custom\+Redis\+Cache}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const bluebird = require('bluebird')}
\DoxyCodeLine{const redis = require("{}redis"{})}
\DoxyCodeLine{bluebird.promisifyAll(redis.RedisClient.prototype)}
\DoxyCodeLine{class MyCustomRedisCache \{}
\DoxyCodeLine{  constructor (opts) \{}
\DoxyCodeLine{    this.redis = redis.createClient(opts)}
\DoxyCodeLine{  \}}
\DoxyCodeLine{  match (req) \{}
\DoxyCodeLine{    return this.redis.getAsync(req.url).then(res => \{}
\DoxyCodeLine{      if (res) \{}
\DoxyCodeLine{        const parsed = JSON.parse(res)}
\DoxyCodeLine{        return new fetch.Response(parsed.body, \{}
\DoxyCodeLine{          url: req.url,}
\DoxyCodeLine{          headers: parsed.headers,}
\DoxyCodeLine{          status: 200}
\DoxyCodeLine{        \})}
\DoxyCodeLine{      \}}
\DoxyCodeLine{    \})}
\DoxyCodeLine{  \}}
\DoxyCodeLine{  put (req, res) \{}
\DoxyCodeLine{    return res.buffer().then(body => \{}
\DoxyCodeLine{      return this.redis.setAsync(req.url, JSON.stringify(\{}
\DoxyCodeLine{        body: body,}
\DoxyCodeLine{        headers: res.headers.raw()}
\DoxyCodeLine{      \}))}
\DoxyCodeLine{    \}).then(() => \{}
\DoxyCodeLine{      // return the response itself}
\DoxyCodeLine{      return res}
\DoxyCodeLine{    \})}
\DoxyCodeLine{  \}}
\DoxyCodeLine{  'delete' (req) \{}
\DoxyCodeLine{    return this.redis.unlinkAsync(req.url)}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16954}{}\doxysubsubsection{$<$a name=\char`\"{}opts-\/cache\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+cache$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16954}
This option follows the standard {\ttfamily fetch} API cache option. This option will do nothing if \href{\#opts-cache-manager}{\texttt{ {\ttfamily opts.\+cache\+Manager}}} is null. The following values are accepted (as strings)\+:


\begin{DoxyItemize}
\item {\ttfamily default} -\/ Fetch will inspect the HTTP cache on the way to the network. If there is a fresh response it will be used. If there is a stale response a conditional request will be created, and a normal request otherwise. It then updates the HTTP cache with the response. If the revalidation request fails (for example, on a 500 or if you\textquotesingle{}re offline), the stale response will be returned.
\item {\ttfamily no-\/store} -\/ Fetch behaves as if there is no HTTP cache at all.
\item {\ttfamily reload} -\/ Fetch behaves as if there is no HTTP cache on the way to the network. Ergo, it creates a normal request and updates the HTTP cache with the response.
\item {\ttfamily no-\/cache} -\/ Fetch creates a conditional request if there is a response in the HTTP cache and a normal request otherwise. It then updates the HTTP cache with the response.
\item {\ttfamily force-\/cache} -\/ Fetch uses any response in the HTTP cache matching the request, not paying attention to staleness. If there was no response, it creates a normal request and updates the HTTP cache with the response.
\item {\ttfamily only-\/if-\/cached} -\/ Fetch uses any response in the HTTP cache matching the request, not paying attention to staleness. If there was no response, it returns a network error. (Can only be used when request’s mode is \char`\"{}same-\/origin\char`\"{}. Any cached redirects will be followed assuming request’s redirect mode is \char`\"{}follow\char`\"{} and the redirects do not violate request’s mode.)
\end{DoxyItemize}

(Note\+: option descriptions are taken from \href{https://fetch.spec.whatwg.org/\#http-network-or-cache-fetch}{\texttt{ https\+://fetch.\+spec.\+whatwg.\+org/\#http-\/network-\/or-\/cache-\/fetch}})\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16955}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16955}

\begin{DoxyCode}{0}
\DoxyCodeLine{const fetch = require('make-\/fetch-\/happen').defaults(\{}
\DoxyCodeLine{  cacheManager: './my-\/cache'}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{// Will error with ENOTCACHED if we haven't already cached this url}
\DoxyCodeLine{fetch('https://registry.npmjs.org/make-\/fetch-\/happen', \{}
\DoxyCodeLine{  cache: 'only-\/if-\/cached'}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{// Will refresh any local content and cache the new response}
\DoxyCodeLine{fetch('https://registry.npmjs.org/make-\/fetch-\/happen', \{}
\DoxyCodeLine{  cache: 'reload'}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{// Will use any local data, even if stale. Otherwise, will hit network.}
\DoxyCodeLine{fetch('https://registry.npmjs.org/make-\/fetch-\/happen', \{}
\DoxyCodeLine{  cache: 'force-\/cache'}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16956}{}\doxysubsubsection{$<$a name=\char`\"{}opts-\/proxy\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+proxy$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16956}
A string or {\ttfamily url.\+parse}-\/d URI to proxy through. Different Proxy handlers will be used depending on the proxy\textquotesingle{}s protocol.

Additionally, {\ttfamily process.\+env.\+HTTP\+\_\+\+PROXY}, {\ttfamily process.\+env.\+HTTPS\+\_\+\+PROXY}, and {\ttfamily process.\+env.\+PROXY} are used if present and no {\ttfamily opts.\+proxy} value is provided.

(Pending) {\ttfamily process.\+env.\+NO\+\_\+\+PROXY} may also be configured to skip proxying requests for all, or specific domains.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16957}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16957}

\begin{DoxyCode}{0}
\DoxyCodeLine{fetch('https://registry.npmjs.org/make-\/fetch-\/happen', \{}
\DoxyCodeLine{  proxy: 'https://corporate.yourcompany.proxy:4445'}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{fetch('https://registry.npmjs.org/make-\/fetch-\/happen', \{}
\DoxyCodeLine{  proxy: \{}
\DoxyCodeLine{    protocol: 'https:',}
\DoxyCodeLine{    hostname: 'corporate.yourcompany.proxy',}
\DoxyCodeLine{    port: 4445}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16958}{}\doxysubsubsection{$<$a name=\char`\"{}opts-\/no-\/proxy\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+no\+Proxy$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16958}
If present, should be a comma-\/separated string or an array of domain extensions that a proxy should {\itshape not} be used for.

This option may also be provided through {\ttfamily process.\+env.\+NO\+\_\+\+PROXY}.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16959}{}\doxysubsubsection{$<$a name=\char`\"{}https-\/opts\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+ca, opts.\+cert, opts.\+key, opts.\+strict\+SSL$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16959}
These values are passed in directly to the HTTPS agent and will be used for both proxied and unproxied outgoing HTTPS requests. They mostly correspond to the same options the {\ttfamily https} module accepts, which will be themselves passed to {\ttfamily tls.\+connect()}. {\ttfamily opts.\+strict\+SSL} corresponds to {\ttfamily reject\+Unauthorized}.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16960}{}\doxysubsubsection{$<$a name=\char`\"{}opts-\/local-\/address\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+local\+Address$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16960}
Passed directly to {\ttfamily http} and {\ttfamily https} request calls. Determines the local address to bind to.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16961}{}\doxysubsubsection{$<$a name=\char`\"{}opts-\/max-\/sockets\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+max\+Sockets$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16961}
Default\+: 15

Maximum number of active concurrent sockets to use for the underlying Http/\+Https/\+Proxy agents. This setting applies once per spawned agent.

15 is probably a {\itshape pretty good value} for most use-\/cases, and balances speed with, uh, not knocking out people\textquotesingle{}s routers. 🤓\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16962}{}\doxysubsubsection{$<$a name=\char`\"{}opts-\/retry\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+retry$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16962}
An object that can be used to tune request retry settings. Retries will only be attempted on the following conditions\+:


\begin{DoxyItemize}
\item Request method is NOT {\ttfamily POST} AND
\item Request status is one of\+: {\ttfamily 408}, {\ttfamily 420}, {\ttfamily 429}, or any status in the 500-\/range. OR
\item Request errored with {\ttfamily ECONNRESET}, {\ttfamily ECONNREFUSED}, {\ttfamily EADDRINUSE}, {\ttfamily ETIMEDOUT}, or the {\ttfamily fetch} error {\ttfamily request-\/timeout}.
\end{DoxyItemize}

The following are worth noting as explicitly not retried\+:


\begin{DoxyItemize}
\item {\ttfamily getaddrinfo ENOTFOUND} and will be assumed to be either an unreachable domain or the user will be assumed offline. If a response is cached, it will be returned immediately.
\item {\ttfamily ECONNRESET} currently has no support for restarting. It will eventually be supported but requires a bit more juggling due to streaming.
\end{DoxyItemize}

If {\ttfamily opts.\+retry} is {\ttfamily false}, it is equivalent to {\ttfamily \{retries\+: 0\}}

If {\ttfamily opts.\+retry} is a number, it is equivalent to {\ttfamily \{retries\+: num\}}

The following retry options are available if you want more control over it\+:


\begin{DoxyItemize}
\item retries
\item factor
\item min\+Timeout
\item max\+Timeout
\item randomize
\end{DoxyItemize}

For details on what each of these do, refer to the \href{https://npm.im/retry}{\texttt{ {\ttfamily retry}}} documentation.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16963}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16963}

\begin{DoxyCode}{0}
\DoxyCodeLine{fetch('https://flaky.site.com', \{}
\DoxyCodeLine{  retry: \{}
\DoxyCodeLine{    retries: 10,}
\DoxyCodeLine{    randomize: true}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{fetch('http://reliable.site.com', \{}
\DoxyCodeLine{  retry: false}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{fetch('http://one-\/more.site.com', \{}
\DoxyCodeLine{  retry: 3}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16964}{}\doxysubsubsection{$<$a name=\char`\"{}opts-\/onretry\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+on\+Retry$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16964}
A function called whenever a retry is attempted.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16965}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16965}

\begin{DoxyCode}{0}
\DoxyCodeLine{fetch('https://flaky.site.com', \{}
\DoxyCodeLine{  onRetry() \{}
\DoxyCodeLine{    console.log('we will retry!')}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16966}{}\doxysubsubsection{$<$a name=\char`\"{}opts-\/integrity\char`\"{}$>$$<$/a$>$ $<$tt$>$$>$ opts.\+integrity$<$/tt$>$}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16966}
Matches the response body against the given \href{https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity}{\texttt{ Subresource Integrity}} metadata. If verification fails, the request will fail with an {\ttfamily EINTEGRITY} error.

{\ttfamily integrity} may either be a string or an \href{https://npm.im/ssri}{\texttt{ {\ttfamily ssri}}} {\ttfamily Integrity}-\/like.\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16967}{}\doxyparagraph{Example}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16967}

\begin{DoxyCode}{0}
\DoxyCodeLine{fetch('https://registry.npmjs.org/make-\/fetch-\/happen/-\//make-\/fetch-\/happen-\/1.0.0.tgz', \{}
\DoxyCodeLine{  integrity: 'sha1-\/o47j7zAYnedYFn1dF/fR9OV3z8Q='}
\DoxyCodeLine{\}) // -\/> ok}
\DoxyCodeLine{}
\DoxyCodeLine{fetch('https://malicious-\/registry.org/make-\/fetch-\/happen/-\//make-\/fetch-\/happen-\/1.0.0.tgz', \{}
\DoxyCodeLine{  integrity: 'sha1-\/o47j7zAYnedYFn1dF/fR9OV3z8Q='}
\DoxyCodeLine{\}) // Error: EINTEGRITY }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16968}{}\doxysubsection{$<$a name=\char`\"{}wow\char`\"{}$>$$<$/a$>$ Message From Our Sponsors}\label{md_sfcode_node_modules_make_fetch_happen_README_autotoc_md16968}


 