private static HttpRequestMessage CreateHttpRequestMessage()

in LogicAppsSampleTestFramework/TestFramework/HttpRequestMessageFeature.cs [57:95]


        private static HttpRequestMessage CreateHttpRequestMessage(HttpContext httpContext)
        {
            HttpRequestMessage message = null;
            try
            {
                var httpRequest = httpContext.Request;
                var uriString =
                    httpRequest.Scheme + "://" +
                    httpRequest.Host +
                    httpRequest.PathBase +
                    httpRequest.Path +
                    httpRequest.QueryString;

                message = new HttpRequestMessage(new HttpMethod(httpRequest.Method), uriString);

                // This allows us to pass the message through APIs defined in legacy code and then
                // operate on the HttpContext inside.
                message.Properties[nameof(HttpContext)] = httpContext;

                message.Content = new StreamContent(httpRequest.Body);

                foreach (var header in httpRequest.Headers)
                {
                    // Every header should be able to fit into one of the two header collections.
                    // Try message.Headers first since that accepts more of them.
                    if (!message.Headers.TryAddWithoutValidation(header.Key, (IEnumerable<string>)header.Value))
                    {
                        var added = message.Content.Headers.TryAddWithoutValidation(header.Key, (IEnumerable<string>)header.Value);
                    }
                }

                return message;
            }
            catch (Exception)
            {
                message?.Dispose();
                throw;
            }
        }