/// <summary>
        /// Serialize the <paramref name="source"/>.
        /// </summary>
        public static async Task <RequestData> FromAsync(this RequestData target, HttpRequest source, CancellationToken cancellationToken = default)
        {
            // Verify that we can convert the string to an HttpMethod
            VerifyMethodName(source.Method);
            target.Method = source.Method;

            target.EncodedUrl    = source.GetEncodedUrl();
            target.Headers       = new Dictionary <string, StringValues>();
            target.ContentType   = source.ContentType;
            target.ContentLength = source.ContentLength;
            target.Headers       = CopyWithoutContentHeaders(source.Headers);


            target.BodyAsString = await source.GetRequestBodyAsync();

            return(target);

            void VerifyMethodName(string methodName)
            {
                try
                {
                    _ = new HttpMethod(methodName);
                }
                catch (Exception e)
                {
                    InternalContract.Fail($"The following HTTP method is not recognized: {methodName}: {e.Message}");
                }
            }
        }