private static string GetString(RequestContent content)
        {
            using var stream = new MemoryStream();
            content.WriteTo(stream, CancellationToken.None);

            return Encoding.UTF8.GetString(stream.ToArray());
        }
Esempio n. 2
0
        internal static byte[] GetRequestContent(RequestContent content)
        {
            using MemoryStream st = new MemoryStream();

            content.WriteTo(st, CancellationToken.None);

            return(st.ToArray());
        }
Esempio n. 3
0
        private static byte[] ReadToEnd(RequestContent requestContent)
        {
            if (requestContent == null)
            {
                return(null);
            }

            using var memoryStream = new MemoryStream();
            requestContent.WriteTo(memoryStream, CancellationToken.None);
            return(memoryStream.ToArray());
        }
Esempio n. 4
0
            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());
            }