Exemplo n.º 1
0
        public void SendValidMaxHeaderTableSize()
        {
            var bytes = validHeaderTableSize.ToUVarInt(prefix);

            bytes[0] |= (byte)IndexationType.EncodingContextUpdate;

            var serverCompressionProc = new CompressionProcessor();

            serverCompressionProc.NotifySettingsChanges(newSettingsMaxHeaderTableSize);

            stateBefore = new CompProcState(serverCompressionProc);

            serverCompressionProc.Decompress(bytes);

            stateAfter = new CompProcState(serverCompressionProc);

            serverCompressionProc.Dispose();

            Assert.Equal(newSettingsMaxHeaderTableSize, stateAfter.SettingsHeaderTableSize);
            Assert.Equal(stateBefore.SettingsHeaderTableSize,
                         stateAfter.SettingsHeaderTableSize);
            Assert.Equal(stateBefore.MaxHeaderByteSize,
                         stateBefore.SettingsHeaderTableSize);
            Assert.True(stateAfter.IsSettingHeaderTableSizeReceived ==
                        stateBefore.IsSettingHeaderTableSizeReceived);
            Assert.True(stateAfter.IsSettingHeaderTableSizeReceived);
            Assert.Equal(validHeaderTableSize, stateAfter.MaxHeaderByteSize);
            Assert.True(stateAfter.MaxHeaderByteSize <= stateAfter.SettingsHeaderTableSize);
        }
Exemplo n.º 2
0
        public void ClearReferenceSet()
        {
            var bytes = new byte[] { 0x30 }; // this value depends on pattern

            var clientHeaders = new HeadersList
            {
                new KeyValuePair <string, string>(":method", "get")
            };

            var clientCompressionProc = new CompressionProcessor();
            var serverCompressionProc = new CompressionProcessor();

            serverCompressionProc.Decompress(clientCompressionProc.Compress(clientHeaders));

            stateBefore = new CompProcState(serverCompressionProc);

            Assert.True(stateBefore.LocalRefSet.Count > 0);

            serverCompressionProc.Decompress(bytes);

            stateAfter = new CompProcState(serverCompressionProc);

            serverCompressionProc.Dispose();
            clientCompressionProc.Dispose();

            Assert.True(stateAfter.LocalRefSet == null ||
                        stateAfter.LocalRefSet.Count == 0);
        }
Exemplo n.º 3
0
        public void SendInvalidMaxHeaderTableSize()
        {
            bool isErrorThrown = false;

            var bytes = invalidHeaderTableSize.ToUVarInt(prefix);

            bytes[0] |= (byte)IndexationType.EncodingContextUpdate;

            var serverCompressionProc = new CompressionProcessor();

            serverCompressionProc.NotifySettingsChanges(newSettingsMaxHeaderTableSize);

            stateBefore = new CompProcState(serverCompressionProc);

            try
            {
                serverCompressionProc.Decompress(bytes);
            }
            catch (CompressionError)
            {
                isErrorThrown = true;
            }

            stateAfter = new CompProcState(serverCompressionProc);

            serverCompressionProc.Dispose();

            Assert.True(isErrorThrown);
            Assert.Equal(newSettingsMaxHeaderTableSize, stateAfter.SettingsHeaderTableSize);
            Assert.Equal(stateBefore.SettingsHeaderTableSize,
                         stateAfter.SettingsHeaderTableSize);
            Assert.Equal(stateBefore.MaxHeaderByteSize, stateBefore.SettingsHeaderTableSize);
            Assert.True(stateAfter.IsSettingHeaderTableSizeReceived);
            Assert.NotEqual(invalidHeaderTableSize, stateAfter.MaxHeaderByteSize);
            Assert.True(stateAfter.MaxHeaderByteSize <= stateAfter.SettingsHeaderTableSize);
            Assert.Equal(stateBefore.MaxHeaderByteSize, stateAfter.MaxHeaderByteSize);
        }