<commit_before>﻿namespace AngleSharp.Services.Default
{
    using System;
    using System.Net;

    /// <summary>
    /// Represents the default cookie service. This class can be inherited.
    /// </summary>
    public class MemoryCookieProvider : ICookieProvider
    {
        readonly CookieContainer _container;

        /// <summary>
        /// Creates a new cookie service for non-persistent cookies.
        /// </summary>
        public MemoryCookieProvider()
        {
            _container = new CookieContainer();
        }

        /// <summary>
        /// Gets the associated cookie container.
        /// </summary>
        public CookieContainer Container
        {
            get { return _container; }
        }

        /// <summary>
        /// Gets the cookie value of the given address.
        /// </summary>
        /// <param name="origin">The origin of the cookie (Url).</param>
        /// <returns>The value of the cookie.</returns>
        public String GetCookie(String origin)
        {
            return _container.GetCookieHeader(new Uri(origin));
        }

        /// <summary>
        /// Sets the cookie value for the given address.
        /// </summary>
        /// <param name="origin">The origin of the cookie (Url).</param>
        /// <param name="value">The value of the cookie.</param>
        public void SetCookie(String origin, String value)
        {
            _container.SetCookies(new Uri(origin), value);
        }
    }
}
<commit_msg>Fixed memory cookie provider #431<commit_after>﻿namespace AngleSharp.Services.Default
{
    using System;
    using System.Net;

    /// <summary>
    /// Represents the default cookie service. This class can be inherited.
    /// </summary>
    public class MemoryCookieProvider : ICookieProvider
    {
        private readonly CookieContainer _container;

        /// <summary>
        /// Creates a new cookie service for non-persistent cookies.
        /// </summary>
        public MemoryCookieProvider()
        {
            _container = new CookieContainer();
        }

        /// <summary>
        /// Gets the associated cookie container.
        /// </summary>
        public CookieContainer Container
        {
            get { return _container; }
        }

        /// <summary>
        /// Gets the cookie value of the given address.
        /// </summary>
        /// <param name="url">The origin of the cookie.</param>
        /// <returns>The value of the cookie.</returns>
        public String GetCookie(Url url)
        {
            var uri = new Uri(url.Origin);
            return _container.GetCookieHeader(uri);
        }

        /// <summary>
        /// Sets the cookie value for the given address.
        /// </summary>
        /// <param name="url">The origin of the cookie.</param>
        /// <param name="value">The value of the cookie.</param>
        public void SetCookie(Url url, String value)
        {
            var uri = new Uri(url.Origin);
            var version = value.StartsWith("$Version", StringComparison.OrdinalIgnoreCase);

            if (version)
            {
                var index = value.IndexOf(';') + 1;

                if (index > 0)
                {
                    value = value.Substring(index).TrimStart();
                }
                else
                {
                    value = value.Substring(1);
                }
            }

            _container.SetCookies(uri, value);

            if (version)
            {
                var cookies = _container.GetCookies(uri);

                foreach (Cookie cookie in cookies)
                {
                    cookie.Version = 1;
                }
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.001878690284487386, 'mean_word_length': 1.46006600660066, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1458487', 'n_tokens_mistral': 940, 'n_tokens_neox': 890, 'n_words': 267}