<commit_before>﻿namespace NuPack {
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.ServiceModel.Syndication;
    using System.Xml;
    using NuPack.Resources;

    public class AtomFeedPackageRepository : PackageRepositoryBase {
        private Uri _feedUri;
        
        public AtomFeedPackageRepository(Uri feedUri) {
            if (feedUri == null) {
                throw new ArgumentNullException("feedUri");
            }
            _feedUri = feedUri;
        }

        public override IQueryable<IPackage> GetPackages() {
            return (from item in GetFeedItems()
                    select new FeedPackage(item)).AsQueryable();
        }

        internal IEnumerable<PackageSyndicationItem> GetFeedItems() {
            try {
                using (var feedReader = XmlTextReader.Create(_feedUri.OriginalString)) {
                    return GetFeedItems(feedReader);
                }
            }
            catch (WebException exception) {
                throw new InvalidOperationException(NuPackResources.AtomFeedPackageRepo_InvalidFeedSource, exception);
            }
        }

        internal static IEnumerable<PackageSyndicationItem> GetFeedItems(XmlReader xmlReader) {
            try {
                var feed = SyndicationFeed.Load<PackageSyndicationFeed>(xmlReader);
                return from PackageSyndicationItem item in feed.Items
                       select item;
            }
            catch (XmlException exception) {
                throw new InvalidOperationException(NuPackResources.AtomFeedPackageRepo_InvalidFeedContent, exception);
             }
         }


        public override void AddPackage(IPackage package) {
            throw new NotSupportedException();
        }

        public override void RemovePackage(IPackage package) {
            throw new NotSupportedException();
        }
    }
}<commit_msg>Use default credentials when getting feed items.<commit_after>﻿namespace NuPack {
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.ServiceModel.Syndication;
    using System.Xml;
    using NuPack.Resources;

    public class AtomFeedPackageRepository : PackageRepositoryBase {
        private Uri _feedUri;

        public AtomFeedPackageRepository(Uri feedUri) {
            if (feedUri == null) {
                throw new ArgumentNullException("feedUri");
            }
            _feedUri = feedUri;
        }

        public override IQueryable<IPackage> GetPackages() {
            return (from item in GetFeedItems()
                    select new FeedPackage(item)).AsQueryable();
        }

        internal IEnumerable<PackageSyndicationItem> GetFeedItems() {
            try {
                // Manually create the request to the feed so we can
                // set the default credentials
                var request = WebRequest.Create(_feedUri);
                request.UseDefaultCredentials = true;
                WebResponse response = request.GetResponse();

                using (var feedReader = XmlTextReader.Create(response.GetResponseStream())) {
                    return GetFeedItems(feedReader);
                }
            }
            catch (WebException exception) {
                throw new InvalidOperationException(NuPackResources.AtomFeedPackageRepo_InvalidFeedSource, exception);
            }
        }

        internal static IEnumerable<PackageSyndicationItem> GetFeedItems(XmlReader xmlReader) {
            try {
                var feed = SyndicationFeed.Load<PackageSyndicationFeed>(xmlReader);
                return from PackageSyndicationItem item in feed.Items
                       select item;
            }
            catch (XmlException exception) {
                throw new InvalidOperationException(NuPackResources.AtomFeedPackageRepo_InvalidFeedContent, exception);
            }
        }


        public override void AddPackage(IPackage package) {
            throw new NotSupportedException();
        }

        public override void RemovePackage(IPackage package) {
            throw new NotSupportedException();
        }
    }
}
{'fraction_non_alphanumeric': 0.06489815253434392, 'fraction_numerical': 0.0, 'mean_word_length': 1.984452296819788, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '131433', 'n_tokens_mistral': 1005, 'n_tokens_neox': 951, 'n_words': 234}