internal static Task <JObject> GetJObjectAsync(this HttpSource source, Uri uri, HttpSourceCacheContext cacheContext, ILogger log, CancellationToken token)
        {
            var cacheKey = GetHashKey(uri);

            var request = new HttpSourceCachedRequest(uri.AbsoluteUri, cacheKey, cacheContext)
            {
                EnsureValidContents = stream => CatalogReaderUtility.LoadJson(stream, true),
                IgnoreNotFounds     = false
            };

            return(source.GetAsync(request, ProcessJson, log, token));
        }
        internal static Task <HttpSourceResult> GetNupkgAsync(this HttpSource source, Uri uri, HttpSourceCacheContext cacheContext, ILogger log, CancellationToken token)
        {
            var cacheKey = GetHashKey(uri);

            var request = new HttpSourceCachedRequest(uri.AbsoluteUri, cacheKey, cacheContext)
            {
                IgnoreNotFounds     = false,
                EnsureValidContents = stream =>
                {
                    using (var reader = new PackageArchiveReader(stream, leaveStreamOpen: true))
                    {
                        reader.NuspecReader.GetIdentity();
                    }
                }
            };

            return(source.GetAsync(request, ProcessResult, log, token));
        }
        internal static Task <NuspecReader> GetNuspecAsync(this HttpSource source, Uri uri, HttpSourceCacheContext cacheContext, ILogger log, CancellationToken token)
        {
            var cacheKey = GetHashKey(uri);

            var request = new HttpSourceCachedRequest(uri.AbsoluteUri, cacheKey, cacheContext)
            {
                IgnoreNotFounds     = false,
                EnsureValidContents = stream =>
                {
                    using (var reader = new StreamReader(stream, Encoding.UTF8, false, 8192, true))
                    {
                        XDocument.Load(reader);
                    }
                }
            };

            return(source.GetAsync(request, ProcessNuspec, log, token));
        }