private static async Task <HttpContent> ConvertResponseContentAsync(Windows.Web.Http.IHttpContent content) { var responseStream = await content.ReadAsInputStreamAsync(); var result = new StreamContent(responseStream.AsStreamForRead()); CopyHeaders(content.Headers, result.Headers); return(result); }
/// <summary> /// Converts the convent from Windows.Web.Http.IHttpContent to System.Net.Http.HttpContent. /// </summary> /// <param name="content">The Windows.Web.Http.IHttpContent to convert.</param> /// <param name="cancellationToken">The operation cancellation token.</param> /// <returns>Converted System.Net.Http.HttpContent.</returns> private static async Task <HttpContent> ConvertContent( Windows.Web.Http.IHttpContent content, CancellationToken cancellationToken) { // If no content to convert if (content == null) { return(null); } // Convert the content var stream = await content.ReadAsInputStreamAsync().AsTask(cancellationToken).ConfigureAwait(false); var converted = new StreamContent(stream.AsStreamForRead()); // Copy content headers foreach (var header in content.Headers) { converted.Headers.TryAddWithoutValidation(header.Key, header.Value); } // Return the converted content return(converted); }