Esempio n. 1
0
        public static async Task RespondRegistrationsBaseUrlAsync(
            this INugetServerProvider provider,
            HttpContext context)
        {
            var excludeSemVer2Package = true;
            var useGzip = false;

            /*
             * Gzip does NOT work.
             */
            //if (provider.IsMatchResource(context,
            //    NugetServerResourceType.RegistrationsBaseUrl_3_6_0))
            //{
            //    useGzip = true;
            //    excludeSemVer2Package = false;
            //}
            //if (provider.IsMatchResource(context,
            //    NugetServerResourceType.RegistrationsBaseUrl_3_4_0))
            //{
            //    useGzip = true;
            //}
            var req = provider.GetRequestingMetadata(context);

            if (!req.IsValid())
            {
                provider.RespondNotFound(context);
                return;
            }
            var nuspecs = provider.NuspecProvider.GetAll()
                          .Where(nuspec => nuspec.Metadata != null)
                          .Where(n => n.Metadata.Id.ToLowerInvariant()
                                 == req.Id)
                          .Where(n => excludeSemVer2Package == false ||
                                 !((NuGetVersionString)n.Metadata.Version).IsSemVer2);

            if (!nuspecs.Any())
            {
                provider.RespondNotFound(context);
                return;
            }
            if (req.IsRequestingIndex())
            {
                await provider.RespondRegistrationIndexAsync(
                    context, req, nuspecs,
                    useGzip : useGzip);

                return;
            }
            if (req.IsRequestingPage())
            {
                //Do some stuff...
                return;
            }
            provider.RespondNotFound(context);
        }