<commit_before>﻿/*
 * Copyright (c) <NAME>.  All rights reserved.
 * see license.txt
 */

using System;
using System.Net.Http;
using System.Web;

namespace Thinktecture.IdentityModel.Extensions
{
    public static class HttpRequestMessageExtensions
    {
        public static HttpRequestMessage ToHttpRequestMessage(this HttpRequestBase httpRequest)
        {
            HttpMethod httpMethod = GetHttpMethod(httpRequest.HttpMethod);
            Uri url = httpRequest.Url;
            
            HttpRequestMessage httpRequestMessage = new HttpRequestMessage(httpMethod, url)
            {
                Content = new StreamContent(httpRequest.InputStream)
            };

            foreach (string str in httpRequest.Headers)
            {
                string[] values = httpRequest.Headers.GetValues(str);
                AddHeaderToHttpRequestMessage(httpRequestMessage, str, values);
            }
            
            return httpRequestMessage;
        }

        internal static HttpMethod GetHttpMethod(string method)
        {
            if (string.IsNullOrEmpty(method))
            {
                return null;
            }
            if (string.Equals("GET", method, StringComparison.OrdinalIgnoreCase))
            {
                return HttpMethod.Get;
            }
            if (string.Equals("POST", method, StringComparison.OrdinalIgnoreCase))
            {
                return HttpMethod.Post;
            }
            if (string.Equals("PUT", method, StringComparison.OrdinalIgnoreCase))
            {
                return HttpMethod.Put;
            }<commit_msg>Minor tweak to HttpRequestMessage extensions<commit_after>﻿/*
 * Copyright (c) <NAME>.  All rights reserved.
 * see license.txt
 */

using System;
using System.Net.Http;
using System.Web;

namespace Thinktecture.IdentityModel.Extensions
{
    public static class HttpRequestMessageExtensions
    {
        public static HttpRequestMessage ToHttpRequestMessage(this HttpRequestBase httpRequest, bool includeContent = true)
        {
            var httpMethod = GetHttpMethod(httpRequest.HttpMethod);
            var url = httpRequest.Url;
            
            var httpRequestMessage = new HttpRequestMessage(httpMethod, url);
            
            if (includeContent)
            {
                httpRequestMessage.Content = new StreamContent(httpRequest.InputStream);
            }
            
            foreach (string str in httpRequest.Headers)
            {
                var values = httpRequest.Headers.GetValues(str);
                AddHeaderToHttpRequestMessage(httpRequestMessage, str, values);
            }
            
            return httpRequestMessage;
        }

        internal static HttpMethod GetHttpMethod(string method)
        {
            if (string.IsNullOrEmpty(method))
            {
                return null;
            }
            if (string.Equals("GET", method, StringComparison.OrdinalIgnoreCase))
            {
                return HttpMethod.Get;
            }
            if (string.Equals("POST", method, StringComparison.OrdinalIgnoreCase))
            {
                return HttpMethod.Post;
            }
            if (string.Equals("PUT", method, StringComparison.OrdinalIgnoreCase))
            {
                return HttpMethod.Put;
            }
{'fraction_non_alphanumeric': 0.07436281859070465, 'fraction_numerical': 0.0, 'mean_word_length': 1.773067331670823, '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': '6003550', 'n_tokens_mistral': 784, 'n_tokens_neox': 765, 'n_words': 171}