Example #1
0
        public void ClientPriorityUsedFact()
        {
            var provider         = new ApplicationLayerProtocolProvider(false, ApplicationLayerProtocolType.Http2_Tls, ApplicationLayerProtocolType.Http1_1);
            var selectedProtocol = provider.ProcessExtension(new BigEndianAdvancingSpan(_httpOneAndTwoWithTls));

            Assert.Equal(ApplicationLayerProtocolType.Http1_1, selectedProtocol);
        }
Example #2
0
        public void InvalidVectorLength()
        {
            var provider = new ApplicationLayerProtocolProvider(false, ApplicationLayerProtocolType.Spdy2);

            Assert.Throws <Alerts.AlertException>(() =>
            {
                var selectedProtocol = provider.ProcessExtension(new BigEndianAdvancingSpan(_badVectorLength));
            });
        }
Example #3
0
        public void NoProtocolMatchesFact()
        {
            var provider = new ApplicationLayerProtocolProvider(false, ApplicationLayerProtocolType.Spdy2);

            Assert.Throws <Alerts.AlertException>(() =>
            {
                var selectedProtocol = provider.ProcessExtension(new BigEndianAdvancingSpan(_httpOneAndTwoWithTls));
            });
        }
Example #4
0
        public async Task Http11CorrectBufferReturned()
        {
            var provider = new ApplicationLayerProtocolProvider(false, ApplicationLayerProtocolType.Http1_1, ApplicationLayerProtocolType.Http2_Tls);

            using (var bufferPool = new MemoryPool())
            {
                var factory = new PipeOptions(bufferPool);
                var channel = new Pipe(factory);
                var writer  = new WriterWrapper(channel.Writer.Alloc(), null);
                provider.WriteExtension(ref writer, ApplicationLayerProtocolType.Http1_1);
                await writer.FlushAsync();

                var readResult = await channel.Reader.ReadAsync();

                var extension = readResult.Buffer.ToArray();
                channel.Reader.Advance(readResult.Buffer.End);
                Assert.Equal(_http11Only, extension);
            }
        }