getCachedRequestURL method

HttpResponse? getCachedRequestURL(
  1. HttpMethod method,
  2. String requestURL, {
  3. Credential? authorization,
  4. Map<String, String?>? queryParameters,
  5. Object? body,
  6. String? contentType,
  7. String? accept,
})

Gets a request already in cache using httpClient and requestURL.

Implementation

HttpResponse? getCachedRequestURL(
  HttpMethod method,
  String requestURL, {
  Credential? authorization,
  Map<String, String?>? queryParameters,
  Object? body,
  String? contentType,
  String? accept,
}) {
  var cacheRequest = _CacheRequest(
    method,
    requestURL,
    queryParameters,
    body,
    contentType,
    accept,
    authorization,
  );
  var cachedEntry = _cache[cacheRequest];

  // An expired entry: not returned (as by [requestURL]).
  var cachedResponse =
      cachedEntry != null &&
          cachedEntry.request.isValid(timeout.inMilliseconds)
      ? cachedEntry.response
      : null;

  if (cachedResponse != null) {
    if (verbose) {
      _log('Cached request: $method > $requestURL > $cachedResponse');
    }
    return cachedResponse;
  }

  return null;
}