Esempio n. 1
0
        public void DataIsMultipleOfChunkSize1()
        {
            var factory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MinSize);
            var request = new DefaultFullHttpRequest(HttpVersion.Http11, HttpMethod.Post, "http://localhost");
            var encoder = new HttpPostRequestEncoder(factory, request, true,
                                                     HttpPostRequestEncoder.EncoderMode.RFC1738);

            var first = new MemoryFileUpload("resources", "", "application/json", null, Encoding.UTF8, -1);

            first.MaxSize = -1;
            first.SetContent(new MemoryStream(new byte[7955]));
            encoder.AddBodyHttpData(first);

            var second = new MemoryFileUpload("resources2", "", "application/json", null, Encoding.UTF8, -1);

            second.MaxSize = -1;
            second.SetContent(new MemoryStream(new byte[7928]));
            encoder.AddBodyHttpData(second);

            Assert.NotNull(encoder.FinalizeRequest());

            CheckNextChunkSize(encoder, 8080);
            CheckNextChunkSize(encoder, 8055);

            IHttpContent httpContent = encoder.ReadChunk(default(IByteBufferAllocator));

            Assert.True(httpContent is ILastHttpContent, "Expected LastHttpContent is not received");
            httpContent.Release();

            Assert.True(encoder.IsEndOfInput, "Expected end of input is not receive");
        }
        public void MemoryFileUploadEquals()
        {
            var f1 = new MemoryFileUpload("m1", "m1", "application/json", null, null, 100);

            Assert.Equal(f1, f1);
        }