private static IByteBuffer Encode(params byte[][] entries)
        {
            HpackEncoder hpackEncoder = Http2TestUtil.NewTestEncoder();
            var          output       = Unpooled.Buffer();
            var          http2Headers = new DefaultHttp2Headers(false);

            for (int ix = 0; ix < entries.Length;)
            {
                http2Headers.Add(new AsciiString(entries[ix++], false), new AsciiString(entries[ix++], false));
            }
            hpackEncoder.EncodeHeaders(3 /* randomly chosen */, output, http2Headers, NeverSensitiveDetector.Instance);
            return(output);
        }
예제 #2
0
        private HpackEncoder CreateEncoder()
        {
            int maxHeaderTableSize = this.maxHeaderTableSize;

            if (maxHeaderTableSize == -1)
            {
                maxHeaderTableSize = int.MaxValue;
            }

            try
            {
                return(Http2TestUtil.NewTestEncoder(true, Http2CodecUtil.MaxHeaderListSize, maxHeaderTableSize));
            }
            catch (Http2Exception e)
            {
                throw new Exception("invalid initial values!", e);
            }
        }
 public DefaultHttp2HeadersEncoderTest()
 {
     encoder = new DefaultHttp2HeadersEncoder(NeverSensitiveDetector.Instance, Http2TestUtil.NewTestEncoder());
 }
예제 #4
0
        public Http2FrameRoundtripTest()
        {
            this.alloc = new Mock <IByteBufferAllocator>();
            this.alloc.Setup(x => x.Buffer()).Returns(() => Unpooled.Buffer());
            this.alloc.Setup(x => x.Buffer(It.IsAny <int>())).Returns <int>(c => Unpooled.Buffer(c));
            this.channel  = new Mock <IChannel>();
            this.executor = new Mock <IEventExecutor>();
            this.listener = new Mock <IHttp2FrameListener>();
            this.ctx      = new Mock <IChannelHandlerContext>();
            this.ctx.Setup(x => x.Allocator).Returns(this.alloc.Object);
            this.ctx.Setup(x => x.Executor).Returns(this.executor.Object);
            this.ctx.Setup(x => x.Channel).Returns(this.channel.Object);
            this.ctx.Setup(x => x.NewPromise()).Returns(() => new DefaultPromise());

            this.writer = new DefaultHttp2FrameWriter(new DefaultHttp2HeadersEncoder(NeverSensitiveDetector.Instance, Http2TestUtil.NewTestEncoder()));
            this.reader = new DefaultHttp2FrameReader(new DefaultHttp2HeadersDecoder(false, Http2TestUtil.NewTestDecoder()));
        }