/// <summary> /// Initializes a new instance of the <see cref="Content"/> class from <paramref name="content"/>. /// </summary> /// <param name="content">The <see cref="HttpContent"/> to initialize from.</param> public Content(HttpContent content) { if (content != null) { var bodyBytes = content.ReadAsByteArrayAsync().Result; Size = bodyBytes.Length; MimeType = content.Headers?.ContentType?.ToString(); if (content.IsBinary()) { Text = Convert.ToBase64String(bodyBytes); Encoding = EncodingBase64; } else { Text = System.Text.Encoding.UTF8.GetString(bodyBytes); } } }