Ideally, we'd cache at the HTTP layer for more reliable tests
511897
private static function cache_wp_files() {
		self::$cache_dir = sys_get_temp_dir() . '/wp-cli-test core-download-cache';

		if ( is_readable( self::$cache_dir . '/wp-config-sample.php' ) )
			return;

		$cmd = Utils\esc_cmd( 'wp core download --force --path=%s', self::$cache_dir );
		Process::create( $cmd, null, self::get_process_env_variables() )->run_check();
	}
891834
function cachepath(location) {
    var uri = url.parse(location);
    if (!uri.protocol) {
        throw new Error('Invalid URL: ' + location);
    } else {
        var hash = crypto.createHash('md5')
            .update(location)
            .digest('hex')
            .substr(0,8) +
            '-' + path.basename(uri.pathname, path.extname(uri.pathname));
        var extname = path.extname(uri.pathname);
        return _(['.shp', '.zip', '']).include(extname.toLowerCase()) ?
            path.join(hash, hash + extname)
            : path.join(hash + extname);
    }
}
426191
function isCached(config) {
        var cache;
        var defaultCache = $cacheFactory.get('$http');
        var defaults = $httpProvider.defaults;

        // Choose the proper cache source. Borrowed from angular: $http service
        if ((config.cache || defaults.cache) && config.cache !== false &&
          (config.method === 'GET' || config.method === 'JSONP')) {
            cache = angular.isObject(config.cache) ? config.cache
              : angular.isObject(defaults.cache) ? defaults.cache
              : defaultCache;
        }

        var cached = cache !== undefined ?
          cache.get(config.url) !== undefined : false;

        if (config.cached !== undefined && cached !== config.cached) {
          return config.cached;
        }
        config.cached = cached;
        return cached;
      }
1014717
def is_local_url(target):
    """"""
    ref_url = urlparse(cfg.get('CFG_SITE_SECURE_URL'))
    test_url = urlparse(urljoin(cfg.get('CFG_SITE_SECURE_URL'), target))
    return test_url.scheme in ('http', 'https') and \
        ref_url.netloc == test_url.netloc
752290
def cache_data(self, request, data, key='params'):
        
        request.session['%s:%s' % (constants.SESSION_KEY, key)] = data
1202560
function(url, prev, done) {
                url = normUrl(url
                    , prev.replace(/^\/(file|https?)(\/.*)/, '$1:/$2')
                );

                load(url, false, function(status, res) {
                    done({
                        file: url.replace(/^\/(file|https?):\/(.*)/, '$1$2'),
                        contents: res.data
                    });
                });
            }
1105280
function makeServeMiddleware(/* config */) {
  return function handle(req, resp, next) {
    if (/^\/.*\.css$/.test(req.url)) {
      resp.end("");
    }
    else {
      next();
    }
  };
}
343435
public ParallelTaskBuilder prepareHttpPut(String url) {
        reinitIfClosed();
        ParallelTaskBuilder cb = new ParallelTaskBuilder();
        cb.getHttpMeta().setHttpMethod(HttpMethod.PUT);
        cb.getHttpMeta().setRequestUrlPostfix(url);
        return cb;

    }
915531
async function fetchCacheableResource(request) {
  const cache = await caches.open(CACHE_NAME);
  const cachedResponse = await cache.match(request);

  if (!navigator.onLine) {
    // We are offline, and we know it.  Just return the cached response, to
    // avoid a bunch of pointless errors in the JS console that will confuse
    // us developers.  If there is no cached response, this will just be a
    // failed request.
    return cachedResponse;
  }

  if (cachedResponse) {
    // We have it in cache.  Try to fetch a live version and update the cache,
    // but limit how long we will wait for the updated version.
    try {
      return timeout(NETWORK_TIMEOUT, fetchAndCache(cache, request));
    } catch (error) {
      // We tried to fetch a live version, but it either failed or took too
      // long.  If it took too long, the fetch and cache operation will continue
      // in the background.  In both cases, we should go ahead with a cached
      // version.
      return cachedResponse;
    }
  } else {
    // We should have this in cache, but we don't.  Fetch and cache a fresh
    // copy and then return it.
    return fetchAndCache(cache, request);
  }
}
680746
function loadRemoteRawData(url) {
  if (!url) {
    // TODO: we should return reject with an appropriate error
    return Promise.resolve(null)
  }

  return new Promise((resolve, reject) => {
    request(url, (error, result) => {
      if (error) {
        reject(error);
      }
      const responseError = detectResponseError(result);
      if (responseError) {
        reject(responseError);
        return;
      }
      resolve(result.response)
    })
  });
}
910072
public boolean usesSecureSite(HttpServletRequest req) {

        CmsSite site = matchRequest(req);
        if (site == null) {
            return false;
        }
        CmsSiteMatcher secureMatcher = site.getSecureServerMatcher();
        boolean result = false;
        if (secureMatcher != null) {
            result = secureMatcher.equals(getRequestMatcher(req));
        }
        return result;
    }
252730
public boolean shouldNotCache(String requestUri) {
		String uri = requestUri.toLowerCase();
		return checkContains(uri, noCacheIdentifiers) || checkSuffixes(uri, noCacheSuffixes);
	}
212077
def _UpdateSessionIfRequired(self, request_headers, response_result, response_headers):    
        

        '''if this request was made with consistency level as session, then update
        the session'''

        if response_result is None or response_headers is None:
            return

        is_session_consistency = False
        if http_constants.HttpHeaders.ConsistencyLevel in request_headers:
            if documents.ConsistencyLevel.Session == request_headers[http_constants.HttpHeaders.ConsistencyLevel]:
                is_session_consistency = True
              
        if is_session_consistency:
            # update session
            self.session.update_session(response_result, response_headers)
838231
function(url, callback) {
    if (this.cache[url]) {
      return callback && callback(null, this.cache[url]);
    }

    debug('GET ' + url);
    var protocol = this._getProtocol(url);
    protocol.get(url, function(res) {
      if (res.statusCode !== 200) {
        return callback && callback(
          new Error('Bad status ' + res.statusCode + ' for ' + url));
      }

      res.setEncoding('utf-8');
      var result = '';
      res.on('data', function(data) {
        result += data;
      });
      res.on('end', function() {
        this.cache[url] = result;
        return callback && callback(null, result);
      }.bind(this));
    }.bind(this)).on('error', function(e) {
      return callback && callback(e);
    });
  }
830615
function (url) {
        var self = this;
        this.searching = true;
        this.loadingError = false;
        return $http.get(url)
          .success(function (res) {
            self.searching = false;
            return res.data;
          })
          .error(function () {
            self.searching = false;
            self.loadingError = true;
            return false;
          });
      }
954932
def background_visit(url, opts = {})
      require 'httpclient'
      begin
        client = HTTPClient.new
        if url && url =~ /^http/
            http_response = client.get(url).body
        else
            base_url = $TESTWISE_PROJECT_BASE_URL || $TESTWISE_PROJECT_BASE_URL || $BASE_URL
            http_response = client.get("#{base_url}#{url}").body
        end
				
				http_response = http_response.content if http_response.respond_to?("content")
      rescue => e
        raise e
      end
    end
34931
def build_response(
        self, request, response, from_cache=False, cacheable_methods=None
    ):
        
        cacheable = cacheable_methods or self.cacheable_methods
        if not from_cache and request.method in cacheable:
            # Check for any heuristics that might update headers
            # before trying to cache.
            if self.heuristic:
                response = self.heuristic.apply(response)

            # apply any expiration heuristics
            if response.status == 304:
                # We must have sent an ETag request. This could mean
                # that we've been expired already or that we simply
                # have an etag. In either case, we want to try and
                # update the cache if that is the case.
                cached_response = self.controller.update_cached_response(
                    request, response
                )

                if cached_response is not response:
                    from_cache = True

                # We are done with the server response, read a
                # possible response body (compliant servers will
                # not return one, but we cannot be 100% sure) and
                # release the connection back to the pool.
                response.read(decode_content=False)
                response.release_conn()

                response = cached_response

            # We always cache the 301 responses
            elif response.status == 301:
                self.controller.cache_response(request, response)
            else:
                # Wrap the response file with a wrapper that will cache the
                #   response when the stream has been consumed.
                response._fp = CallbackFileWrapper(
                    response._fp,
                    functools.partial(
                        self.controller.cache_response, request, response
                    ),
                )
                if response.chunked:
                    super_update_chunk_length = response._update_chunk_length

                    def _update_chunk_length(self):
                        super_update_chunk_length()
                        if self.chunk_left == 0:
                            self._fp._close()

                    response._update_chunk_length = types.MethodType(
                        _update_chunk_length, response
                    )

        resp = super(CacheControlAdapter, self).build_response(request, response)

        # See if we should invalidate the cache.
        if request.method in self.invalidating_methods and resp.ok:
            cache_url = self.controller.cache_url(request.url)
            self.cache.delete(cache_url)

        # Give the request a from_cache attr to let people use it
        resp.from_cache = from_cache

        return resp