<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Winter;

namespace WinterExtensions
{
    public class WinterOptions
    {
        string m_channel;
        string m_url, m_key;

        public bool WebApiEnabled { get { Uri uri; return Uri.TryCreate(m_url, UriKind.Absolute, out uri) && uri.Scheme == Uri.UriSchemeHttp; } }
        public string WebApi { get { return m_url; } }
        public string WebApiKey { get { return m_key; } }

        public WinterOptions(Options options)
        {
            m_channel = options.Channel.ToLower();

            IniSection section = options.IniReader.GetSectionByName("winter");
            if (section == null)
                return;

            section.GetValue("WebApi", ref m_url);
            section.GetValue("ApiKey", ref m_key);
        }


        public HttpWebRequest CreateGetRequest(string api, bool compressed, string values = null)
        {
            values = string.IsNullOrWhiteSpace(values) ? "" : "&" + values;
            string url = string.Format("{0}/getpoints.php?CHANNEL={1}{2}", m_url, m_channel, values);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "GET";
            request.KeepAlive = false;
            
            if (compressed)
                request.ContentType = "application/x-gzip";

            if (!string.IsNullOrWhiteSpace(m_key))
                request.Headers.Add("APIKey", m_key);

            return request;
        }

        public HttpWebRequest CreatePostRequest(string api, bool compressed, string values = null)
        {
            values = string.IsNullOrWhiteSpace(values) ? "" : "&" + values;
            string url = string.Format("{0}/{1}?CHANNEL={2}{3}", m_url, api, m_channel, values);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.KeepAlive = false;

            if (compressed)
                request.ContentType = "application/x-gzip";

            if (!string.IsNullOrWhiteSpace(m_key))
                request.Headers.Add("APIKey", m_key);

            return request;
        }
    }
}<commit_msg>Fix CreateGetRequest bug<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Winter;

namespace WinterExtensions
{
    public class WinterOptions
    {
        string m_channel;
        string m_url, m_key;

        public bool WebApiEnabled { get { Uri uri; return Uri.TryCreate(m_url, UriKind.Absolute, out uri) && uri.Scheme == Uri.UriSchemeHttp; } }
        public string WebApi { get { return m_url; } }
        public string WebApiKey { get { return m_key; } }

        public WinterOptions(Options options)
        {
            m_channel = options.Channel.ToLower();

            IniSection section = options.IniReader.GetSectionByName("winter");
            if (section == null)
                return;

            section.GetValue("WebApi", ref m_url);
            section.GetValue("ApiKey", ref m_key);
        }


        public HttpWebRequest CreateGetRequest(string api, bool compressed, string values = null)
        {
            values = string.IsNullOrWhiteSpace(values) ? "" : "&" + values;
            string url = string.Format("{0}/{1}?CHANNEL={2}{3}", m_url, api, m_channel, values);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "GET";
            request.KeepAlive = false;
            
            if (compressed)
                request.ContentType = "application/x-gzip";

            if (!string.IsNullOrWhiteSpace(m_key))
                request.Headers.Add("APIKey", m_key);

            return request;
        }

        public HttpWebRequest CreatePostRequest(string api, bool compressed, string values = null)
        {
            values = string.IsNullOrWhiteSpace(values) ? "" : "&" + values;
            string url = string.Format("{0}/{1}?CHANNEL={2}{3}", m_url, api, m_channel, values);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.KeepAlive = false;

            if (compressed)
                request.ContentType = "application/x-gzip";

            if (!string.IsNullOrWhiteSpace(m_key))
                request.Headers.Add("APIKey", m_key);

            return request;
        }

        public string GetUrl(string api, string values=null)
        {
            values = string.IsNullOrWhiteSpace(values) ? "" : "&" + values;
            return string.Format("{0}/{1}?CHANNEL={2}{3}", m_url, api, m_channel, values);
        }
    }
}
{'fraction_non_alphanumeric': 0.11251816483288354, 'fraction_numerical': 0.003944363711853851, 'mean_word_length': 2.199203187250996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5552701', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1316, 'n_words': 294}