Пример #1
0
        public virtual void GlobalSetup()
        {
            _memoryPool = PinnedBlockMemoryPoolFactory.Create();
            _httpFrame  = new Http2Frame();

            var options = new PipeOptions(_memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);

            _connectionPair = DuplexPipe.CreateConnectionPair(options, options);

            _httpRequestHeaders = new HttpRequestHeaders();
            _httpRequestHeaders[HeaderNames.Method]    = new StringValues("GET");
            _httpRequestHeaders[HeaderNames.Path]      = new StringValues("/");
            _httpRequestHeaders[HeaderNames.Scheme]    = new StringValues("http");
            _httpRequestHeaders[HeaderNames.Authority] = new StringValues("localhost:80");

            _headersBuffer = new byte[1024 * 16];
            _hpackEncoder  = new DynamicHPackEncoder();

            var serviceContext = TestContextFactory.CreateServiceContext(
                serverOptions: new KestrelServerOptions(),
                dateHeaderValueManager: new DateHeaderValueManager(),
                systemClock: new MockSystemClock(),
                log: new MockTrace());

            serviceContext.DateHeaderValueManager.OnHeartbeat(default);
Пример #2
0
    public StartLineTests()
    {
        MemoryPool = PinnedBlockMemoryPoolFactory.Create();
        var options = new PipeOptions(MemoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
        var pair    = DuplexPipe.CreateConnectionPair(options, options);

        Transport = pair.Transport;

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

        var connectionContext = TestContextFactory.CreateHttpConnectionContext(
            serviceContext: serviceContext,
            connectionContext: Mock.Of <ConnectionContext>(),
            transport: Transport,
            timeoutControl: new TimeoutControl(timeoutHandler: null),
            memoryPool: MemoryPool,
            connectionFeatures: new FeatureCollection());

        Http1Connection = new Http1Connection(connectionContext);

        Parser         = new HttpParser <Http1ParsingHandler>(showErrorDetails: true);
        ParsingHandler = new Http1ParsingHandler(Http1Connection);
    }
        public void GlobalSetup()
        {
            _memoryPool = PinnedBlockMemoryPoolFactory.Create();

            var options = new PipeOptions(_memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);

            _pipe = new Pipe(options);

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

            _frameWriter = new Http2FrameWriter(
                new NullPipeWriter(),
                connectionContext: null,
                http2Connection: null,
                new OutputFlowControl(new SingleAwaitableProvider(), initialWindowSize: int.MaxValue),
                timeoutControl: null,
                minResponseDataRate: null,
                "TestConnectionId",
                _memoryPool,
                serviceContext);

            _responseHeaders = new HttpResponseHeaders();
            var headers = (IHeaderDictionary)_responseHeaders;

            headers.ContentType   = "application/json";
            headers.ContentLength = 1024;
        }
Пример #4
0
        public TestInput(IKestrelTrace log = null, ITimeoutControl timeoutControl = null)
        {
            _memoryPool = PinnedBlockMemoryPoolFactory.Create();
            var options = new PipeOptions(pool: _memoryPool, 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>());

            Http1ConnectionContext = TestContextFactory.CreateHttpConnectionContext(
                serviceContext: new TestServiceContext
            {
                Log = log ?? Mock.Of <IKestrelTrace>()
            },
                connectionContext: Mock.Of <ConnectionContext>(),
                transport: Transport,
                timeoutControl: timeoutControl ?? Mock.Of <ITimeoutControl>(),
                memoryPool: _memoryPool,
                connectionFeatures: connectionFeatures);

            Http1Connection = new Http1Connection(Http1ConnectionContext);
            Http1Connection.HttpResponseControl = Mock.Of <IHttpResponseControl>();
            Http1Connection.Reset();
        }
Пример #5
0
        public void Setup()
        {
            _memoryPool = PinnedBlockMemoryPoolFactory.Create();
            var pipe = new Pipe(new PipeOptions(_memoryPool));

            _reader = pipe.Reader;
            _writer = pipe.Writer;
        }
        public void Setup()
        {
            var memoryPool = PinnedBlockMemoryPoolFactory.Create();
            var options    = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair       = DuplexPipe.CreateConnectionPair(options, options);

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

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

            var http1Connection = new Http1Connection(connectionContext);

            http1Connection.Reset();
            serviceContext.DateHeaderValueManager.OnHeartbeat(DateTimeOffset.UtcNow);

            _responseHeadersDirect = (HttpResponseHeaders)http1Connection.ResponseHeaders;
            var context = new DefaultHttpContext(http1Connection);

            _response = context.Response;

            switch (Type)
            {
            case BenchmarkTypes.ContentLengthNumeric:
                SetContentLengthNumeric(1);
                GetContentLengthNumeric(1);
                break;

            case BenchmarkTypes.ContentLengthString:
                SetContentLengthString(1);
                GetContentLengthString(1);
                break;

            case BenchmarkTypes.Plaintext:
                SetPlaintext(1);
                GetPlaintext(1);
                break;

            case BenchmarkTypes.Common:
                SetCommon(1);
                GetCommon(1);
                break;

            case BenchmarkTypes.Unknown:
                SetUnknown(1);
                GetUnknown(1);
                break;
            }
        }
Пример #7
0
        public LibuvOutputConsumerTests()
        {
            _memoryPool = PinnedBlockMemoryPoolFactory.Create();
            _mockLibuv  = new MockLibuv();

            var context = new TestLibuvTransportContext();

            _libuvThread = new LibuvThread(_mockLibuv, context, maxLoops: 1);
            _libuvThread.StartAsync().Wait();
        }
Пример #8
0
        public static HttpMultiplexedConnectionContext CreateHttp3ConnectionContext(
            MultiplexedConnectionContext connectionContext = null,
            ServiceContext serviceContext         = null,
            IFeatureCollection connectionFeatures = null,
            MemoryPool <byte> memoryPool          = null,
            IPEndPoint localEndPoint       = null,
            IPEndPoint remoteEndPoint      = null,
            ITimeoutControl timeoutControl = null)
        {
            var http3ConnectionContext = new HttpMultiplexedConnectionContext(
                "TestConnectionId",
                connectionContext ?? new TestMultiplexedConnectionContext(),
                serviceContext ?? CreateServiceContext(new KestrelServerOptions()),
                connectionFeatures ?? new FeatureCollection(),
                memoryPool ?? PinnedBlockMemoryPoolFactory.Create(),
                localEndPoint,
                remoteEndPoint);

            http3ConnectionContext.TimeoutControl = timeoutControl;

            return(http3ConnectionContext);
        }
    public void InitialDictionaryIsEmpty()
    {
        using (var memoryPool = PinnedBlockMemoryPoolFactory.Create())
        {
            var options = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair    = DuplexPipe.CreateConnectionPair(options, options);
            var http1ConnectionContext = TestContextFactory.CreateHttpConnectionContext(
                serviceContext: new TestServiceContext(),
                connectionContext: Mock.Of <ConnectionContext>(),
                transport: pair.Transport,
                memoryPool: memoryPool,
                connectionFeatures: new FeatureCollection());

            var http1Connection = new Http1Connection(http1ConnectionContext);

            http1Connection.Reset();

            IDictionary <string, StringValues> headers = http1Connection.ResponseHeaders;

            Assert.Equal(0, headers.Count);
            Assert.False(headers.IsReadOnly);
        }
    }
    public HttpProtocolFeatureCollection()
    {
        var memoryPool = PinnedBlockMemoryPoolFactory.Create();
        var options    = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
        var pair       = DuplexPipe.CreateConnectionPair(options, options);

        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,
            memoryPool: memoryPool,
            connectionFeatures: new FeatureCollection());

        var http1Connection = new Http1Connection(connectionContext);

        http1Connection.Reset();

        _collection = http1Connection;
    }
Пример #11
0
        public void Setup()
        {
            var memoryPool = PinnedBlockMemoryPoolFactory.Create();
            var options    = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false);
            var pair       = DuplexPipe.CreateConnectionPair(options, options);

            var serviceContext = TestContextFactory.CreateServiceContext(
                serverOptions: new KestrelServerOptions(),
                httpParser: NullParser <Http1ParsingHandler> .Instance);

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

            var http1Connection = new Http1Connection(connectionContext);

            http1Connection.Reset();

            _http1Connection = http1Connection;
        }
Пример #12
0
 public void GlobalSetup()
 {
     _memoryPool              = PinnedBlockMemoryPoolFactory.Create();
     _http1Connection         = MakeHttp1Connection();
     _consumeResponseBodyTask = ConsumeResponseBody();
 }
Пример #13
0
 public void GlobalSetup()
 {
     _memoryPool      = PinnedBlockMemoryPoolFactory.Create();
     _http1Connection = MakeHttp1Connection();
 }
Пример #14
0
 public OutputProducerTests()
 {
     _memoryPool = PinnedBlockMemoryPoolFactory.Create();
 }
Пример #15
0
 public void Setup()
 {
     _memoryPool = PinnedBlockMemoryPoolFactory.Create();
     _pipe       = new Pipe(new PipeOptions(_memoryPool));
 }