<commit_before>﻿#if NET35
using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Diagnostics;
using Twilio.Exceptions;
using Newtonsoft.Json;

namespace Twilio.Http
{
    public class WebRequestClient : HttpClient
    {
        private const string PlatVersion = " (.NET 3.5)";

        public override Response MakeRequest(Request request)
        {
            var httpRequest = BuildHttpRequest(request);
            if (!Equals(request.Method, HttpMethod.Get))
            {
                var stream = GetStream(httpRequest);
                stream.Write(request.EncodePostParams(), 0, request.EncodePostParams().Length);
            }

            try
            {
                var response = GetResponse(httpRequest);
                var reader = new StreamReader(response.GetResponseStream());
                return new Response(response.StatusCode, reader.ReadToEnd());
            }
            catch (WebException e)
            {
                throw HandleErrorResponse((HttpWebResponse) e.Response);
            }
        }

        private static Exception HandleErrorResponse(HttpWebResponse errorResponse)
        {
            if (errorResponse.StatusCode >= HttpStatusCode.InternalServerError &&
                errorResponse.StatusCode < HttpStatusCode.HttpVersionNotSupported)
            {
                return new TwilioException("Internal Server error: " + errorResponse.StatusDescription);
            }

            var responseStream = errorResponse.GetResponseStream();
            var errorReader = new StreamReader(responseStream);
            var errorContent = errorReader.ReadToEnd();<commit_msg>Fix hang in .NET 3.5 WebRequestClient<commit_after>﻿#if NET35
using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Diagnostics;
using Twilio.Exceptions;
using Newtonsoft.Json;

namespace Twilio.Http
{
    public class WebRequestClient : HttpClient
    {
        private const string PlatVersion = " (.NET 3.5)";

        public override Response MakeRequest(Request request)
        {
            var httpRequest = BuildHttpRequest(request);
            if (!Equals(request.Method, HttpMethod.Get))
            {
                var stream = GetStream(httpRequest);
                stream.Write(request.EncodePostParams(), 0, request.EncodePostParams().Length);
                stream.Close();
            }

            try
            {
                var response = GetResponse(httpRequest);
                var reader = new StreamReader(response.GetResponseStream());
                return new Response(response.StatusCode, reader.ReadToEnd());
            }
            catch (WebException e)
            {
                throw HandleErrorResponse((HttpWebResponse) e.Response);
            }
        }

        private static Exception HandleErrorResponse(HttpWebResponse errorResponse)
        {
            if (errorResponse.StatusCode >= HttpStatusCode.InternalServerError &&
                errorResponse.StatusCode < HttpStatusCode.HttpVersionNotSupported)
            {
                return new TwilioException("Internal Server error: " + errorResponse.StatusDescription);
            }

            var responseStream = errorResponse.GetResponseStream();
            var errorReader = new StreamReader(responseStream);
            var errorContent = errorReader.ReadToEnd();
{'fraction_non_alphanumeric': 0.08068315665488811, 'fraction_numerical': 0.0035335689045936395, 'mean_word_length': 2.1688432835820897, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7641573', 'n_tokens_mistral': 795, 'n_tokens_neox': 770, 'n_words': 183}