private static string GetString(RequestContent content) { using var stream = new MemoryStream(); content.WriteTo(stream, CancellationToken.None); return Encoding.UTF8.GetString(stream.ToArray()); }
internal static byte[] GetRequestContent(RequestContent content) { using MemoryStream st = new MemoryStream(); content.WriteTo(st, CancellationToken.None); return(st.ToArray()); }
private static byte[] ReadToEnd(RequestContent requestContent) { if (requestContent == null) { return(null); } using var memoryStream = new MemoryStream(); requestContent.WriteTo(memoryStream, CancellationToken.None); return(memoryStream.ToArray()); }
private async ValueTask <byte[]> FormatAsync(RequestContent requestContent, bool async) { using var memoryStream = new MaxLengthStream(_maxLength); if (async) { await requestContent.WriteToAsync(memoryStream, _cancellationToken).ConfigureAwait(false); } else { requestContent.WriteTo(memoryStream, _cancellationToken); } return(memoryStream.ToArray()); }