示例#1
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);
    }
示例#2
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 = 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(),
                log: new MockTrace());

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

            var http1Connection = new Http1Connection(connectionContext);

            http1Connection.Reset();

            Http1Connection = http1Connection;
            Pipe            = new Pipe(new PipeOptions(_memoryPool));
        }
示例#4
0
    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());

        _frameWriter = new Http2FrameWriter(
            new NullPipeWriter(),
            connectionContext: null,
            http2Connection: null,
            maxStreamsPerConnection: 1,
            timeoutControl: null,
            minResponseDataRate: null,
            "TestConnectionId",
            _memoryPool,
            serviceContext);

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

        headers.ContentType   = "application/json";
        headers.ContentLength = 1024;
    }
示例#5
0
        public virtual void GlobalSetup()
        {
            _memoryPool = SlabMemoryPoolFactory.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.HeaderMethod    = new StringValues("GET");
            _httpRequestHeaders.HeaderPath      = new StringValues("/");
            _httpRequestHeaders.HeaderScheme    = new StringValues("http");
            _httpRequestHeaders.HeaderAuthority = new StringValues("localhost:80");

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

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

            serviceContext.DateHeaderValueManager.OnHeartbeat(default);
        public HttpProtocolFeatureCollection()
        {
            var memoryPool = SlabMemoryPoolFactory.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(),
                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();

            _collection = http1Connection;
        }
示例#7
0
        public void GlobalSetup()
        {
            _memoryPool = SlabMemoryPoolFactory.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();
            _responseHeaders.HeaderContentType   = "application/json";
            _responseHeaders.HeaderContentLength = "1024";
        }
        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;
            }
        }
示例#9
0
    public virtual void GlobalSetup()
    {
        _headerHandler            = new Http3RequestHeaderHandler();
        _requestHeadersEnumerator = new Http3HeadersEnumerator();
        _httpFrame = new Http3FrameWithPayload();

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

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

        serviceContext.DateHeaderValueManager.OnHeartbeat(default);
        public void Setup()
        {
            var memoryPool = SlabMemoryPoolFactory.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>());

            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();

            Connection = http1Connection;
        }
        private Http2FrameWriter CreateFrameWriter(Pipe pipe)
        {
            var serviceContext = TestContextFactory.CreateServiceContext(new KestrelServerOptions(), log: Mock.Of <IKestrelTrace>());

            return(new Http2FrameWriter(pipe.Writer, null, null, null, null, null, null, _dirtyMemoryPool, serviceContext));
        }