Ejemplo n.º 1
0
        public void Setup()
        {
            var bufferPool = new MemoryPool();
            var pair       = PipeFactory.CreateConnectionPair(bufferPool);

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new TestHttp1Connection(new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                BufferPool         = bufferPool,
                TimeoutControl     = new MockTimeoutControl(),
                Application        = pair.Application,
                Transport          = pair.Transport
            });

            http1Connection.Reset();

            _http1Connection = http1Connection;
        }
Ejemplo n.º 2
0
        private TestHttp1Connection MakeHttp1Connection()
        {
            var options = new PipeOptions(_memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            _pair = pair;

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new TestHttp1Connection(new HttpConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _memoryPool,
                TimeoutControl     = new TimeoutControl(timeoutHandler: null),
                Transport          = pair.Transport
            });

            http1Connection.Reset();
            http1Connection.InitializeBodyControl(MessageBody.ZeroContentLengthKeepAlive);
            serviceContext.DateHeaderValueManager.OnHeartbeat(DateTimeOffset.UtcNow);

            return(http1Connection);
        }
Ejemplo n.º 3
0
        public Http1ConnectionTests()
        {
            _pipelineFactory = KestrelMemoryPool.Create();
            var options = new PipeOptions(_pipelineFactory, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            _transport   = pair.Transport;
            _application = pair.Application;

            var connectionFeatures = new FeatureCollection();

            connectionFeatures.Set(Mock.Of <IConnectionLifetimeFeature>());
            connectionFeatures.Set(Mock.Of <IBytesWrittenFeature>());

            _serviceContext         = new TestServiceContext();
            _timeoutControl         = new Mock <ITimeoutControl>();
            _http1ConnectionContext = new Http1ConnectionContext
            {
                ServiceContext     = _serviceContext,
                ConnectionContext  = Mock.Of <ConnectionContext>(),
                ConnectionFeatures = connectionFeatures,
                MemoryPool         = _pipelineFactory,
                TimeoutControl     = _timeoutControl.Object,
                Application        = pair.Application,
                Transport          = pair.Transport
            };

            _http1Connection = new TestHttp1Connection(_http1ConnectionContext);
            _http1Connection.Reset();
        }
Ejemplo n.º 4
0
        private TestHttp1Connection MakeHttp1Connection()
        {
            var options = new PipeOptions(_memoryPool, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            _pair = pair;

            var serviceContext = TestContextFactory.CreateServiceContext(
                serverOptions: new KestrelServerOptions(),
                httpParser: new HttpParser <Http1ParsingHandler>(),
                dateHeaderValueManager: new DateHeaderValueManager());

            var connectionContext = TestContextFactory.CreateHttpConnectionContext(
                serviceContext: serviceContext,
                connectionContext: null,
                transport: pair.Transport,
                timeoutControl: new TimeoutControl(timeoutHandler: null),
                memoryPool: _memoryPool,
                connectionFeatures: new FeatureCollection());

            var http1Connection = new TestHttp1Connection(connectionContext);

            http1Connection.Reset();
            http1Connection.InitializeBodyControl(MessageBody.ZeroContentLengthKeepAlive);
            serviceContext.DateHeaderValueManager.OnHeartbeat(DateTimeOffset.UtcNow);

            return(http1Connection);
        }
        public void Setup()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var options = new PipeOptions(_memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);

            _pair = DuplexPipe.CreateConnectionPair(options, options);

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new TestHttp1Connection(new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _memoryPool,
                TimeoutControl     = new MockTimeoutControl(),
                Application        = _pair.Application,
                Transport          = _pair.Transport
            });

            http1Connection.Reset();

            _http1Connection = http1Connection;
        }
Ejemplo n.º 6
0
        public HttpProtocolFeatureCollectionTests()
        {
            _memoryPool = KestrelMemoryPool.Create();
            var options = new PipeOptions(_memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            _transport   = pair.Transport;
            _application = pair.Application;

            _serviceContext         = new TestServiceContext();
            _timeoutControl         = new Mock <ITimeoutControl>();
            _http1ConnectionContext = new Http1ConnectionContext
            {
                ServiceContext     = _serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _memoryPool,
                TimeoutControl     = _timeoutControl.Object,
                Application        = pair.Application,
                Transport          = pair.Transport
            };

            _http1Connection = new TestHttp1Connection(_http1ConnectionContext);
            _http1Connection.Reset();
            _collection = _http1Connection;
        }
        private TestHttp1Connection MakeHttp1Connection()
        {
            var pair = DuplexPipe.CreateConnectionPair(_memoryPool);

            _pair = pair;

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log        = new MockTrace(),
                HttpParser = new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new TestHttp1Connection(new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _memoryPool,
                Application        = pair.Application,
                Transport          = pair.Transport
            });

            http1Connection.Reset();
            http1Connection.InitializeStreams(MessageBody.ZeroContentLengthKeepAlive);

            return(http1Connection);
        }
Ejemplo n.º 8
0
        public override void Initialize(TestContext context, MethodInfo methodInfo, object[] testMethodArguments, ITestOutputHelper testOutputHelper)
        {
            base.Initialize(context, methodInfo, testMethodArguments, testOutputHelper);

            _pipelineFactory = PinnedBlockMemoryPoolFactory.Create();
            var options = new PipeOptions(_pipelineFactory, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);

            _transport   = pair.Transport;
            _application = pair.Application;

            var connectionFeatures = new FeatureCollection();

            connectionFeatures.Set(Mock.Of <IConnectionLifetimeFeature>());

            _serviceContext = new TestServiceContext(LoggerFactory)
            {
                Scheduler = PipeScheduler.Inline
            };

            _timeoutControl         = new Mock <ITimeoutControl>();
            _http1ConnectionContext = TestContextFactory.CreateHttpConnectionContext(
                serviceContext: _serviceContext,
                connectionContext: Mock.Of <ConnectionContext>(),
                transport: pair.Transport,
                timeoutControl: _timeoutControl.Object,
                memoryPool: _pipelineFactory,
                connectionFeatures: connectionFeatures);

            _http1Connection = new TestHttp1Connection(_http1ConnectionContext);
        }
Ejemplo n.º 9
0
        public void Setup()
        {
            var pipeFactory = new PipeFactory();
            var pair        = pipeFactory.CreateConnectionPair();

            var serviceContext = new ServiceContext
            {
                DateHeaderValueManager = new DateHeaderValueManager(),
                ServerOptions          = new KestrelServerOptions(),
                Log = new MockTrace(),
                HttpParserFactory = f => new HttpParser <Http1ParsingHandler>()
            };

            var http1Connection = new TestHttp1Connection <object>(application: null, context: new Http1ConnectionContext
            {
                ServiceContext     = serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                PipeFactory        = pipeFactory,
                TimeoutControl     = new MockTimeoutControl(),
                Application        = pair.Application,
                Transport          = pair.Transport
            });

            http1Connection.Reset();

            _http1Connection = http1Connection;
        }
Ejemplo n.º 10
0
        public Http1HttpProtocolFeatureCollectionTests()
        {
            var context = TestContextFactory.CreateHttpConnectionContext(
                connectionContext: Mock.Of <ConnectionContext>(),
                serviceContext: new TestServiceContext(),
                transport: Mock.Of <IDuplexPipe>(),
                connectionFeatures: new FeatureCollection(),
                timeoutControl: Mock.Of <ITimeoutControl>());

            _httpConnectionContext = context;
            _http1Connection       = new TestHttp1Connection(context);
            _http1Connection.Reset();
            _collection = _http1Connection;
        }
Ejemplo n.º 11
0
        public HttpProtocolFeatureCollectionTests()
        {
            _http1ConnectionContext = new HttpConnectionContext
            {
                ServiceContext     = new TestServiceContext(),
                ConnectionFeatures = new FeatureCollection(),
                TimeoutControl     = Mock.Of <ITimeoutControl>(),
                Transport          = Mock.Of <IDuplexPipe>(),
            };

            _http1Connection = new TestHttp1Connection(_http1ConnectionContext);
            _http1Connection.Reset();
            _collection = _http1Connection;
        }
Ejemplo n.º 12
0
        public HttpProtocolFeatureCollectionTests()
        {
            var context = new Http2StreamContext
            {
                ServiceContext     = new TestServiceContext(),
                ConnectionFeatures = new FeatureCollection(),
                TimeoutControl     = Mock.Of <ITimeoutControl>(),
                Transport          = Mock.Of <IDuplexPipe>(),
                ServerPeerSettings = new Http2PeerSettings(),
                ClientPeerSettings = new Http2PeerSettings(),
            };

            _httpConnectionContext = context;
            _http1Connection       = new TestHttp1Connection(context);
            _http1Connection.Reset();
            _collection = _http1Connection;

            var http2Stream = new TestHttp2Stream(context);

            http2Stream.Reset();
            _http2Collection = http2Stream;
        }
Ejemplo n.º 13
0
        public Http1ConnectionTests()
        {
            _pipelineFactory = new MemoryPool();
            var pair = PipeFactory.CreateConnectionPair(_pipelineFactory);

            _transport   = pair.Transport;
            _application = pair.Application;

            _serviceContext         = new TestServiceContext();
            _timeoutControl         = new Mock <ITimeoutControl>();
            _http1ConnectionContext = new Http1ConnectionContext
            {
                ServiceContext     = _serviceContext,
                ConnectionFeatures = new FeatureCollection(),
                MemoryPool         = _pipelineFactory,
                TimeoutControl     = _timeoutControl.Object,
                Application        = pair.Application,
                Transport          = pair.Transport
            };

            _http1Connection = new TestHttp1Connection(_http1ConnectionContext);
            _http1Connection.Reset();
        }
Ejemplo n.º 14
0
 public void GlobalSetup()
 {
     _memoryPool      = MemoryPoolFactory.Create();
     _http1Connection = MakeHttp1Connection();
 }
Ejemplo n.º 15
0
 public void GlobalSetup()
 {
     _memoryPool      = KestrelMemoryPool.Create();
     _http1Connection = MakeHttp1Connection();
 }
Ejemplo n.º 16
0
 public void GlobalSetup()
 {
     _memoryPool              = PinnedBlockMemoryPoolFactory.Create();
     _http1Connection         = MakeHttp1Connection();
     _consumeResponseBodyTask = ConsumeResponseBody();
 }
Ejemplo n.º 17
0
 public Http1WritingBenchmark()
 {
     _http1Connection = MakeHttp1Connection();
     _writeData       = Encoding.ASCII.GetBytes("Hello, World!");
 }