<commit_before>﻿using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

namespace LtiLibrary.Core.Extensions
{
    internal static class HttpExtensions
    {
        public static async Task<HttpResponseMessage> GetResponseAsync(this HttpRequestMessage message, bool allowAutoRedirect = false)
        {
            using (var handler = new HttpClientHandler() { AllowAutoRedirect = allowAutoRedirect })
            {
                using (var client = new HttpClient(handler))
                {
                    return await client.SendAsync(message);
                }
            }
        }

        public static HttpResponseMessage GetResponse(this HttpRequestMessage message, bool allowAutoRedirect = false)
        {
            return GetResponseAsync(message, allowAutoRedirect).Result;
        }

        public static Stream GetRequestStream(this HttpRequestMessage message)
        {
            return message.Content.ReadAsStreamAsync().Result;
        }

        public static Stream GetResponseStream(this HttpResponseMessage message)
        {
            return message.Content.ReadAsStreamAsync().Result;
        }
        
    }
}
<commit_msg>Remove synchronous GetResponse method (it deadlocks the request thread). Remove GetResponseString method because it may deadklock the thread and it is only a convenience method for debugging.<commit_after>﻿using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

namespace LtiLibrary.Core.Extensions
{
    internal static class HttpExtensions
    {
        public static async Task<HttpResponseMessage> GetResponseAsync(this HttpRequestMessage message, bool allowAutoRedirect = false)
        {
            using (var handler = new HttpClientHandler() { AllowAutoRedirect = allowAutoRedirect })
            {
                using (var client = new HttpClient(handler))
                {
                    return await client.SendAsync(message);
                }
            }
        }

        [Obsolete("Use GetResponseAsync instead.")]
        public static HttpResponseMessage GetResponse(this HttpRequestMessage message, bool allowAutoRedirect = false)
        {
            return GetResponseAsync(message, allowAutoRedirect).Result;
        }

        public static Stream GetResponseStream(this HttpResponseMessage message)
        {
            return message.Content.ReadAsStreamAsync().Result;
        }
        
    }
}

{'fraction_non_alphanumeric': 0.06456885982836126, 'fraction_numerical': 0.0, 'mean_word_length': 2.395284327323162, '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': '7239202', 'n_tokens_mistral': 563, 'n_tokens_neox': 548, 'n_words': 153}