static async Task DecodeTestWith(int[] chunkLengths)
        {
            MockHttpChunkedMessageBody.Generate(
                chunkLengths,
                out List <MemoryStream> chunks,
                out byte[] httpBody
                );
            var bodyStream = new MemoryStream(httpBody);
            var inst       = new HttpChunkedRequestBody(
                new RollbackableStream(bodyStream, TcpSettings.Default),
                new HttpRequestHeader(),
                TcpSettings.Default
                );

            var result = new MemoryStream();
            await inst.CopyToAsync(result);

            Assert.True(
                result.ToArray().SequenceEqual(chunks.SelectMany(m => m.ToArray()))
                );
        }
        public async Task CanHaveTrailer()
        {
            MockHttpChunkedMessageBody.Generate(
                new int[] { 400, 4000 },
                new Dictionary <string, string> {
                { @"Content-Type", "application/json" }
            },
                out List <MemoryStream> chunks,
                out byte[] httpBody
                );
            var header = new HttpRequestHeader();
            var inst   = new HttpChunkedRequestBody(
                new RollbackableStream(new MemoryStream(httpBody), TcpSettings.Default),
                header,
                TcpSettings.Default
                );

            await inst.CopyToAsync(new MemoryStream());

            Assert.True(header.ContainsKey("Content-Type"));
            Assert.Equal("application/json", header["Content-Type"]);
        }