<commit_before>﻿// ------------------------------------------------------------------------------
//                                                                              |
//   Copyright 2012 <NAME>.                                              |
//                                                                              |
//   Licensed under the Apache License, Version 2.0 (the "License");            |
//   you may not use this file except in compliance with the License.           |
//   You may obtain a copy of the License at                                    |
//                                                                              |
//       http://www.apache.org/licenses/LICENSE-2.0                             |
//                                                                              |
//   Unless required by applicable law or agreed to in writing, software        |
//   distributed under the License is distributed on an "AS IS" BASIS,          |
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   |
//   See the License for the specific language governing permissions and        |
//   limitations under the License.                                             |
//                                                                              |
// ------------------------------------------------------------------------------

using System.IO;
using System.Net;
using System.Text;
using System.Collections.Generic;

namespace GaugesNet.Core
{
    internal sealed class Curl
    {
        private HttpWebRequest _request = null;

        private void GetCredentials()
        {
            _request.Credentials = CredentialCache.DefaultCredentials;
            _request.Proxy.Credentials = CredentialCache.DefaultCredentials;
        }

        private string GetResponse(HttpWebRequest request)
        {
            StringBuilder output = new StringBuilder();
            using (StreamReader stream = new StreamReader(request.GetResponse().GetResponseStream()))
            {
                char[] c = null;

                while (!stream.EndOfStream)
                {
                    c = new char[100];
                    stream.ReadBlock(c, 0, c.Length);
                    output.Append(c);
                }
            }
            return output.ToString();
        }

        public string Get(string url, string token)
        {
            _request = (HttpWebRequest)WebRequest.Create(url);
            _request.Headers["X-Gauges-Token"] = token;
            _request.Method = "GET";
            GetCredentials();

            return GetResponse(_request);
        }

        public string Post(string url, string token, Dictionary<string, string> data) 
        {
            StringBuilder putDataBulder = new StringBuilder();
            foreach (KeyValuePair<string, string> item in data)
            {
                putDataBulder.Append(item.Key + "=" + item.Value + "&");
            }

            byte[] putDataArray = Encoding.UTF8.GetBytes(putDataBulder.ToString().TrimEnd('&'));

            _request = (HttpWebRequest)WebRequest.Create(url);
            _request.Headers["X-Gauges-Token"] = token;
            _request.Method = "POST";
            _request.ContentType = "application/x-www-form-urlencoded";
            _request.ContentLength = putDataArray.Length;
            GetCredentials();

            using (Stream requestStream = _request.GetRequestStream())
            {
                requestStream.Write(putDataArray, 0, putDataArray.Length);
            }

            return GetResponse(_request);
        }

        public string Put(string url, string token, Dictionary<string,string> data) 
        {
            StringBuilder putDataBulder = new StringBuilder();
            foreach (KeyValuePair<string,string> item in data)
            {
                putDataBulder.Append(item.Key + "=" + item.Value + "&");
            }

            byte[] putDataArray = Encoding.UTF8.GetBytes(putDataBulder.ToString().TrimEnd('&'));

            _request = (HttpWebRequest)WebRequest.Create(url);
            _request.Headers["X-Gauges-Token"] = token;
            _request.Method = "PUT";
            _request.ContentType = "application/x-www-form-urlencoded";
            _request.ContentLength = putDataArray.Length;
            GetCredentials();

            using (Stream requestStream = _request.GetRequestStream())
            {
                requestStream.Write(putDataArray, 0, putDataArray.Length);
            }
            
            return GetResponse(_request);
        }

        public string Delete(string url, string token) 
        {
            _request = (HttpWebRequest)WebRequest.Create(url);
            _request.Headers["X-Gauges-Token"] = token;
            _request.Method = "DELETE";
            GetCredentials();
            
            return GetResponse(_request);
        }
    }
}
<commit_msg>Remove unused using. Added XML comment<commit_after>﻿// ------------------------------------------------------------------------------
//                                                                              |
//   Copyright 2012 <NAME>.                                              |
//                                                                              |
//   Licensed under the Apache License, Version 2.0 (the "License");            |
//   you may not use this file except in compliance with the License.           |
//   You may obtain a copy of the License at                                    |
//                                                                              |
//       http://www.apache.org/licenses/LICENSE-2.0                             |
//                                                                              |
//   Unless required by applicable law or agreed to in writing, software        |
//   distributed under the License is distributed on an "AS IS" BASIS,          |
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   |
//   See the License for the specific language governing permissions and        |
//   limitations under the License.                                             |
//                                                                              |
// ------------------------------------------------------------------------------

using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;

namespace GaugesNet.Core
{
    /// <summary>
    /// Implements HTTP methods (GET,POST,PUT,DELETE) to communicate with the Gaug.es API.
    /// This class cannot be inherited.
    /// </summary>
    internal sealed class Curl
    {
        private HttpWebRequest _request = null;

        private void GetCredentials()
        {
            _request.Credentials = CredentialCache.DefaultCredentials;
            _request.Proxy.Credentials = CredentialCache.DefaultCredentials;
        }

        private string GetResponse(HttpWebRequest request)
        {
            StringBuilder output = new StringBuilder();
            using (StreamReader stream = new StreamReader(request.GetResponse().GetResponseStream()))
            {
                char[] c = null;

                while (!stream.EndOfStream)
                {
                    c = new char[100];
                    stream.ReadBlock(c, 0, c.Length);
                    output.Append(c);
                }
            }
            return output.ToString();
        }

        public string Get(string url, string token)
        {
            _request = (HttpWebRequest)WebRequest.Create(url);
            _request.Headers["X-Gauges-Token"] = token;
            _request.Method = "GET";
            GetCredentials();

            return GetResponse(_request);
        }

        public string Post(string url, string token, Dictionary<string, string> data) 
        {
            StringBuilder putDataBulder = new StringBuilder();
            foreach (KeyValuePair<string, string> item in data)
            {
                putDataBulder.Append(item.Key + "=" + item.Value + "&");
            }

            byte[] putDataArray = Encoding.UTF8.GetBytes(putDataBulder.ToString().TrimEnd('&'));

            _request = (HttpWebRequest)WebRequest.Create(url);
            _request.Headers["X-Gauges-Token"] = token;
            _request.Method = "POST";
            _request.ContentType = "application/x-www-form-urlencoded";
            _request.ContentLength = putDataArray.Length;
            GetCredentials();

            using (Stream requestStream = _request.GetRequestStream())
            {
                requestStream.Write(putDataArray, 0, putDataArray.Length);
            }

            return GetResponse(_request);
        }

        public string Put(string url, string token, Dictionary<string,string> data) 
        {
            StringBuilder putDataBulder = new StringBuilder();
            foreach (KeyValuePair<string,string> item in data)
            {
                putDataBulder.Append(item.Key + "=" + item.Value + "&");
            }

            byte[] putDataArray = Encoding.UTF8.GetBytes(putDataBulder.ToString().TrimEnd('&'));

            _request = (HttpWebRequest)WebRequest.Create(url);
            _request.Headers["X-Gauges-Token"] = token;
            _request.Method = "PUT";
            _request.ContentType = "application/x-www-form-urlencoded";
            _request.ContentLength = putDataArray.Length;
            GetCredentials();

            using (Stream requestStream = _request.GetRequestStream())
            {
                requestStream.Write(putDataArray, 0, putDataArray.Length);
            }
            
            return GetResponse(_request);
        }

        public string Delete(string url, string token) 
        {
            _request = (HttpWebRequest)WebRequest.Create(url);
            _request.Headers["X-Gauges-Token"] = token;
            _request.Method = "DELETE";
            GetCredentials();
            
            return GetResponse(_request);
        }
    }
}

{'fraction_non_alphanumeric': 0.12003565415469941, 'fraction_numerical': 0.003169258195503615, 'mean_word_length': 1.2702338129496402, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7448900', 'n_tokens_mistral': 2255, 'n_tokens_neox': 2195, 'n_words': 523}