defaultHtmlFetcher function

HtmlFetcher defaultHtmlFetcher({
  1. Duration timeout = const Duration(seconds: 30),
})

The default dart:io HtmlFetcher used when none is injected.

Fails loudly instead of auditing garbage: throws TimeoutException when the server does not answer within timeout and HttpException on a non-2xx status (a 404 page with pretty meta tags must not pass an audit).

Implementation

HtmlFetcher defaultHtmlFetcher({
  Duration timeout = const Duration(seconds: 30),
}) {
  return (Uri uri, {Map<String, String> headers = const {}}) {
    return _httpFetch(uri, headers: headers).timeout(timeout);
  };
}