Ejemplo n.º 1
0
            public void Body_Chunked()
            {
                using (MessageSample sample = CreateMessageSample()) {
                    // ARRANGE

                    // The sample.CheckChunkFlushing is not meaningful with Write() method,
                    // because Write() writes stored body at once.
                    Debug.Assert(sample.CheckChunkFlushing == false);

                    sample.AppendHeader(
                        "PUT / HTTP/1.1",
                        "Host: www.example.org:80",
                        "Transfer-Encoding: chunked",
                        ""
                        );

                    // write chunked body
                    sample.AppendChunkSizeLine("2F");                       // chunk-size, simple
                    sample.AppendRandomChunkData(0x2F);                     // chunk-data
                    sample.AppendChunkSizeLine("08");                       // chunk-size, in redundant format
                    sample.AppendRandomChunkData(0x08);                     // chunk-data
                    sample.AppendChunkSizeLine("000");                      // last-chunk, in redundant format
                    sample.AppendCRLF();

                    // ACT & ASSERT
                    int actualMessageCount = TestReadAndWrite(sample, (request) => {
                        Assert.Equal(-1, request.ContentLength);
                    });
                    Assert.Equal(1, actualMessageCount);
                    sample.AssertOutputEqualToSample();
                }
            }