<commit_before>using System;
using System.Collections.Generic;
using Htc.Vita.Core.Log;
using Htc.Vita.Core.Util;

namespace Htc.Vita.Core.Net
{
    partial class FileDownloader
    {
        internal class MultipleHostHelper
        {
            private List<string> _hostList;
            private int _index = -1;
            private int _retryCount;
            private int _maxRetryCount;

            public MultipleHostHelper(List<string> hostList, int maxRetryCount)
            {
                _hostList = hostList;
                _maxRetryCount = maxRetryCount;
            }

            public string GetNextUrl(string originalUrl)
            {
                _index++;

                if (_retryCount >= _maxRetryCount) return "";
                if (_index >= _hostList.Count)
                {
                    _index = -1;
                    _retryCount++;
                    return GetNextUrl(originalUrl);
                }
                try
                {
                    var uriStringFromNetMethodTargetField = _hostList[_index];
                    var uriDownload = new UriBuilder(uriStringFromNetMethodTargetField);
                    UriBuilder uri;

                    if (!originalUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
                        !originalUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
                    {
                        uri = new UriBuilder($"http://a.b.c/{originalUrl.TrimStart('/')}");
                    }
                    else
                    {
                        uri = new UriBuilder(originalUrl);
                    }

                    uriDownload.Path = uriDownload.Path.Equals("/")
                        ? uri.Path
                        : $"{uriDownload.Path.TrimEnd('/')}{uri.Path}";

                    var query = HttpUtilityLite.ParseQueryString(uri.Query);
                    uriDownload.Query = query.ToString();

                    return uriDownload.ToString();
                }
                catch (Exception exc)
                {
                    Logger.GetInstance(typeof(MultipleHostHelper)).Error($"Exception: {exc}");
                    return GetNextUrl(originalUrl);
                }
            }
        }
    }
}<commit_msg>[FIX] correct parsing queries in NameValueCollection<commit_after>using System;
using System.Collections.Generic;
using Htc.Vita.Core.Log;
using Htc.Vita.Core.Util;

namespace Htc.Vita.Core.Net
{
    partial class FileDownloader
    {
        internal class MultipleHostHelper
        {
            private List<string> _hostList;
            private int _index = -1;
            private int _retryCount;
            private int _maxRetryCount;

            public MultipleHostHelper(List<string> hostList, int maxRetryCount)
            {
                _hostList = hostList;
                _maxRetryCount = maxRetryCount;
            }

            public string GetNextUrl(string originalUrl)
            {
                _index++;

                if (_retryCount >= _maxRetryCount) return "";
                if (_index >= _hostList.Count)
                {
                    _index = -1;
                    _retryCount++;
                    return GetNextUrl(originalUrl);
                }
                try
                {
                    var uriStringFromNetMethodTargetField = _hostList[_index];
                    var uriDownload = new UriBuilder(uriStringFromNetMethodTargetField);
                    UriBuilder uri;

                    if (!originalUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
                        !originalUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
                    {
                        uri = new UriBuilder($"http://a.b.c/{originalUrl.TrimStart('/')}");
                    }
                    else
                    {
                        uri = new UriBuilder(originalUrl);
                    }

                    uriDownload.Path = uriDownload.Path.Equals("/")
                        ? uri.Path
                        : $"{uriDownload.Path.TrimEnd('/')}{uri.Path}";

                    var queries = HttpUtilityLite.ParseQueryString(uri.Query);
                    var queryList = new List<string>();
                    foreach (var item in queries.AllKeys)
                    {
                        queryList.Add($"{item}={queries[item]}");
                    }
                    uriDownload.Query = string.Join("&", queryList);

                    return uriDownload.ToString();
                }
                catch (Exception exc)
                {
                    Logger.GetInstance(typeof(MultipleHostHelper)).Error($"Exception: {exc}");
                    return GetNextUrl(originalUrl);
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09040590405904059, 'fraction_numerical': 0.0008200082000820008, 'mean_word_length': 1.2360219981668195, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3138429', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1111, 'n_words': 206}