示例#1
0
        public void EmptyHeaderValuesCanBeParsed(string rawHeaders, int numHeaders)
        {
            var trace = new KestrelTrace(new TestKestrelTrace());
            var ltp   = new LoggingThreadPool(trace);

            using (var pool = new MemoryPool())
                using (var socketInput = new SocketInput(pool, ltp))
                {
                    var connectionContext = new ConnectionContext()
                    {
                        DateHeaderValueManager = new DateHeaderValueManager(),
                        ServerAddress          = ServerAddress.FromUrl("http://localhost:5000")
                    };
                    var frame            = new Frame <object>(application: null, context: connectionContext);
                    var headerCollection = new FrameRequestHeaders();

                    var headerArray = Encoding.ASCII.GetBytes(rawHeaders);
                    socketInput.IncomingData(headerArray, 0, headerArray.Length);

                    var success = frame.TakeMessageHeaders(socketInput, headerCollection);

                    Assert.True(success);
                    Assert.Equal(numHeaders, headerCollection.Count());

                    // Assert TakeMessageHeaders consumed all the input
                    var scan = socketInput.ConsumingStart();
                    Assert.True(scan.IsEnd);
                }
        }
示例#2
0
        public void EmptyHeaderValuesCanBeParsed(string rawHeaders, int numHeaders)
        {
            var socketInput      = new SocketInput(new MemoryPool2());
            var headerCollection = new FrameRequestHeaders();

            var headerArray = Encoding.ASCII.GetBytes(rawHeaders);
            var inputBuffer = socketInput.IncomingStart(headerArray.Length);

            Buffer.BlockCopy(headerArray, 0, inputBuffer.Data.Array, inputBuffer.Data.Offset, headerArray.Length);
            socketInput.IncomingComplete(headerArray.Length, null);

            var success = Frame.TakeMessageHeaders(socketInput, headerCollection);

            Assert.True(success);
            Assert.Equal(numHeaders, headerCollection.Count());

            // Assert TakeMessageHeaders consumed all the input
            var scan = socketInput.ConsumingStart();

            Assert.True(scan.IsEnd);
        }