const page = await guardedFetch('https://example.com/notes', { maxBytes: 2 * 1024 * 1024, deadlineMs: 10_000 });
page.contentType; // 'text/html'
When maxBytes or deadlineMs is not a positive
number (or deadlineMs is longer than Node's longest timer), or
maxRedirects is not a whole number of 0 or more, before any lookup.
When allowHost is given and is not a function, before any lookup.
When the address, a redirect or the answer is
refused, or the read fails or passes its deadline; reason says which,
and a host rule's own failure is the error's cause.
The reason of options.signal when the caller aborts it.
Reads
address, an http or https address a person gave a server, underoptions. Each hop asks the caller'sallowHost, when given, about the host before anything is resolved, then resolves the host and refuses it when any of its addresses is not public (isPublicAddress) and not inallowAddresses, then connects to a checked address on a connection of its own, trying the next one when the first cannot be reached; a redirect is followed only to an address that passes the same checks, at mostmaxRedirectstimes. The answer must be a 2xx of a type inaccept, and its body, decoded from gzip, deflate or br, is refused once it passesmaxByteson the wire or decoded. The whole read stops atdeadlineMs.