<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;

namespace AppMetrics.Client
{
	public static class HttpUtil
	{
		public static string Request(string url, string method = "GET", Dictionary<string, string> args = null, ICredentials credentials = null)
		{
			var buf = new StringBuilder();
			if (args != null)
			{
				foreach (var val in args)
				{
					buf.AppendFormat("{0}={1}&", Uri.EscapeUriString(val.Key), Uri.EscapeUriString(val.Value));
				}
			}

			if (method == "GET" && buf.Length > 0)
			{
				if (url.Contains("?"))
					url += "&";
				else
					url += "?";
				url += buf;
			}

			var request = (HttpWebRequest)WebRequest.Create(url);
			request.Method = method;
			request.Timeout = 5000;
			request.ReadWriteTimeout = request.Timeout;
			request.Credentials = credentials;

			if (method == "GET")
			{
				request.ContentType = "text/plain; encoding='utf-8'";
			}
			else if (method == "POST")
			{
				request.ContentType = "application/x-www-form-urlencoded; encoding='utf-8'";

				using (var stream = request.GetRequestStream())
				{
					using (var writer = new StreamWriter(stream, Encoding.UTF8))
					{
						writer.Write(buf.ToString());
					}
				}
			}

			var response = request.GetResponse();
			using (var responseStream = response.GetResponseStream())
			{
				using (var reader = new StreamReader(responseStream, Encoding.UTF8))
				{
					return reader.ReadToEnd();
				}
			}
		}

		public static string Request(string url, ICredentials credentials)
		{
			return Request(url, "GET", null, credentials);
		}
	}
}
<commit_msg>refactoring<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;

namespace AppMetrics.Client
{
	public static class HttpUtil
	{
		private const int DefaultTimeout = 100 * 1000;

		public static string Request(string url, string method = "GET", Dictionary<string, string> args = null,
			int timeout = DefaultTimeout, ICredentials credentials = null)
		{
			var buf = new StringBuilder();
			if (args != null)
			{
				foreach (var val in args)
				{
					buf.AppendFormat("{0}={1}&", Uri.EscapeUriString(val.Key), Uri.EscapeUriString(val.Value));
				}
			}

			if (method == "GET" && buf.Length > 0)
			{
				if (url.Contains("?"))
					url += "&";
				else
					url += "?";
				url += buf;
			}

			var request = (HttpWebRequest)WebRequest.Create(url);
			request.Method = method;
			request.Timeout = timeout;
			request.ReadWriteTimeout = request.Timeout;
			request.Credentials = credentials;

			if (method == "GET")
			{
				request.ContentType = "text/plain; encoding='utf-8'";
			}
			else if (method == "POST")
			{
				request.ContentType = "application/x-www-form-urlencoded; encoding='utf-8'";

				using (var stream = request.GetRequestStream())
				{
					using (var writer = new StreamWriter(stream, Encoding.UTF8))
					{
						writer.Write(buf.ToString());
					}
				}
			}

			var response = request.GetResponse();
			using (var responseStream = response.GetResponseStream())
			{
				using (var reader = new StreamReader(responseStream, Encoding.UTF8))
				{
					return reader.ReadToEnd();
				}
			}
		}

		public static string Request(string url, ICredentials credentials, int timeout = DefaultTimeout)
		{
			return Request(url, "GET", null, timeout, credentials);
		}
	}
}

{'fraction_non_alphanumeric': 0.13658820110433015, 'fraction_numerical': 0.007265329845975007, 'mean_word_length': 3.1771844660194173, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3840047', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1072, 'n_words': 257}