private void ParseRequest() { _http1Connection.Reset(); if (!_http1Connection.TakeStartLine(_buffer, out var consumed, out var examined)) { ErrorUtilities.ThrowInvalidRequestLine(); } if (!_http1Connection.TakeMessageHeaders(_buffer, out consumed, out examined)) { ErrorUtilities.ThrowInvalidRequestHeaders(); } }
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; }
public TestInput() { _memoryPool = KestrelMemoryPool.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 = new HttpConnectionContext { ServiceContext = new TestServiceContext(), ConnectionContext = Mock.Of <ConnectionContext>(), ConnectionFeatures = connectionFeatures, Transport = Transport, MemoryPool = _memoryPool, TimeoutControl = Mock.Of <ITimeoutControl>() }; Http1Connection = new Http1Connection(Http1ConnectionContext); Http1Connection.HttpResponseControl = Mock.Of <IHttpResponseControl>(); Http1Connection.Reset(); }
public void Setup() { var pipeFactory = new PipeFactory(); var pair = pipeFactory.CreateConnectionPair(); var serviceContext = new ServiceContext { ServerOptions = new KestrelServerOptions(), HttpParserFactory = f => NullParser <Http1ParsingHandler> .Instance }; var http1Connection = new Http1Connection <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; }
private void ParseRequest() { _http1Connection.Reset(); var reader = new SequenceReader <byte>(_buffer); if (!_http1Connection.TakeStartLine(ref reader)) { ErrorUtilities.ThrowInvalidRequestLine(); } if (!_http1Connection.TakeMessageHeaders(ref reader, trailers: false)) { ErrorUtilities.ThrowInvalidRequestHeaders(); } }
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 Http1Connection <object>(application: null, context: new Http1ConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), PipeFactory = pipeFactory, Application = pair.Application, Transport = pair.Transport, TimeoutControl = new MockTimeoutControl() }); http1Connection.Reset(); Http1Connection = http1Connection; Pipe = pipeFactory.Create(); }
public void Setup() { _memoryPool = SlabMemoryPoolFactory.Create(); var options = new PipeOptions(_memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); var 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 Http1Connection(new HttpConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), MemoryPool = _memoryPool, Transport = pair.Transport, TimeoutControl = new TimeoutControl(timeoutHandler: null) }); http1Connection.Reset(); Http1Connection = http1Connection; Pipe = new Pipe(new PipeOptions(_memoryPool)); }
public void InAbsoluteForm() { var rawTarget = "http://localhost/path1?q=123&w=xyzw"; var path = "/path1"; var query = "?q=123&w=xyzw"; Http1Connection.Reset(); // RawTarget, Path, QueryString are null after reset Assert.Null(Http1Connection.RawTarget); Assert.Null(Http1Connection.Path); Assert.Null(Http1Connection.QueryString); var ros = new ReadOnlySequence <byte>(Encoding.ASCII.GetBytes($"CONNECT {rawTarget} HTTP/1.1\r\n")); Assert.True(Parser.ParseRequestLine(ParsingHandler, ros, out _, out _)); // Equal the inputs. Assert.Equal(rawTarget, Http1Connection.RawTarget); Assert.Equal(path, Http1Connection.Path); Assert.Equal(query, Http1Connection.QueryString); // But not the same as the inputs. Assert.NotSame(rawTarget, Http1Connection.RawTarget); Assert.NotSame(path, Http1Connection.Path); Assert.NotSame(query, Http1Connection.QueryString); }
public HttpProtocolFeatureCollection() { var memoryPool = new MemoryPool(); var pair = DuplexPipe.CreateConnectionPair(memoryPool); var serviceContext = new ServiceContext { DateHeaderValueManager = new DateHeaderValueManager(), ServerOptions = new KestrelServerOptions(), Log = new MockTrace(), HttpParser = new HttpParser <Http1ParsingHandler>() }; var http1Connection = new Http1Connection(new Http1ConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), MemoryPool = memoryPool, Application = pair.Application, Transport = pair.Transport }); http1Connection.Reset(); _http1Connection = http1Connection; }
public HttpProtocolFeatureCollection() { var bufferPool = new MemoryPool(); var pair = PipeFactory.CreateConnectionPair(bufferPool); var serviceContext = new ServiceContext { DateHeaderValueManager = new DateHeaderValueManager(), ServerOptions = new KestrelServerOptions(), Log = new MockTrace(), HttpParserFactory = f => new HttpParser <Http1ParsingHandler>() }; var http1Connection = new Http1Connection <object>(application: null, context: new Http1ConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), BufferPool = bufferPool, Application = pair.Application, Transport = pair.Transport }); http1Connection.Reset(); _http1Connection = http1Connection; }
public void InitialDictionaryIsEmpty() { using (var memoryPool = SlabMemoryPoolFactory.Create()) { var options = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); var pair = DuplexPipe.CreateConnectionPair(options, options); var http1ConnectionContext = new HttpConnectionContext { ServiceContext = new TestServiceContext(), ConnectionFeatures = new FeatureCollection(), MemoryPool = memoryPool, Transport = pair.Transport, TimeoutControl = null }; var http1Connection = new Http1Connection(http1ConnectionContext); http1Connection.Reset(); IDictionary <string, StringValues> headers = http1Connection.ResponseHeaders; Assert.Equal(0, headers.Count); Assert.False(headers.IsReadOnly); } }
private void ParseData() { do { var awaitable = Pipe.Reader.ReadAsync(); if (!awaitable.IsCompleted) { // No more data return; } var result = awaitable.GetAwaiter().GetResult(); var readableBuffer = result.Buffer; Http1Connection.Reset(); if (!Http1Connection.TakeStartLine(readableBuffer, out var consumed, out var examined)) { ErrorUtilities.ThrowInvalidRequestLine(); } Pipe.Reader.Advance(consumed, examined); result = Pipe.Reader.ReadAsync().GetAwaiter().GetResult(); readableBuffer = result.Buffer; if (!Http1Connection.TakeMessageHeaders(readableBuffer, out consumed, out examined)) { ErrorUtilities.ThrowInvalidRequestHeaders(); } Pipe.Reader.Advance(consumed, examined); }while (true); }
public void Setup() { var bufferPool = new MemoryPool(); var pair = PipeFactory.CreateConnectionPair(bufferPool); var serviceContext = new ServiceContext { ServerOptions = new KestrelServerOptions(), HttpParser = NullParser <Http1ParsingHandler> .Instance }; var http1Connection = new Http1Connection(new Http1ConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), BufferPool = bufferPool, TimeoutControl = new MockTimeoutControl(), Application = pair.Application, Transport = pair.Transport }); http1Connection.Reset(); _http1Connection = http1Connection; }
public async Task WriteDataRateTimeoutAbortsConnection() { var mockConnectionContext = new Mock <ConnectionContext>(); var httpConnectionContext = TestContextFactory.CreateHttpConnectionContext( serviceContext: new TestServiceContext(), connectionContext: mockConnectionContext.Object, connectionFeatures: new FeatureCollection(), transport: new DuplexPipe(Mock.Of <PipeReader>(), Mock.Of <PipeWriter>())); var httpConnection = new HttpConnection(httpConnectionContext); var aborted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var http1Connection = new Http1Connection(httpConnectionContext); httpConnection.Initialize(http1Connection); http1Connection.Reset(); http1Connection.RequestAborted.Register(() => { aborted.SetResult(); }); httpConnection.OnTimeout(TimeoutReason.WriteDataRate); mockConnectionContext .Verify(c => c.Abort(It.Is <ConnectionAbortedException>(ex => ex.Message == CoreStrings.ConnectionTimedBecauseResponseMininumDataRateNotSatisfied)), Times.Once); await aborted.Task.DefaultTimeout(); }
public TestInput(KestrelTrace 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 ?? new KestrelTrace(NullLoggerFactory.Instance) }, 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(); }
public void InAsteriskForm() { var rawTarget = "*"; var path = string.Empty; var query = string.Empty; Http1Connection.Reset(); // RawTarget, Path, QueryString are null after reset Assert.Null(Http1Connection.RawTarget); Assert.Null(Http1Connection.Path); Assert.Null(Http1Connection.QueryString); var ros = new ReadOnlySequence <byte>(Encoding.ASCII.GetBytes($"OPTIONS {rawTarget} HTTP/1.1\r\n")); Assert.True(Parser.ParseRequestLine(ParsingHandler, ros, out _, out _)); // Equal the inputs. Assert.Equal(rawTarget, Http1Connection.RawTarget); Assert.Equal(path, Http1Connection.Path); Assert.Equal(query, Http1Connection.QueryString); // Asterisk is interned string, so the same. Assert.Same(rawTarget, Http1Connection.RawTarget); // Empty strings, so interned and the same. Assert.Same(path, Http1Connection.Path); Assert.Same(query, Http1Connection.QueryString); }
public void InOriginForm() { var rawTarget = "/path%20with%20spaces?q=123&w=xyzw1"; var path = "/path with spaces"; var query = "?q=123&w=xyzw1"; Http1Connection.Reset(); // RawTarget, Path, QueryString are null after reset Assert.Null(Http1Connection.RawTarget); Assert.Null(Http1Connection.Path); Assert.Null(Http1Connection.QueryString); var ros = new ReadOnlySequence <byte>(Encoding.ASCII.GetBytes($"POST {rawTarget} HTTP/1.1\r\n")); var reader = new SequenceReader <byte>(ros); Assert.True(Parser.ParseRequestLine(ParsingHandler, ref reader)); // Equal the inputs. Assert.Equal(rawTarget, Http1Connection.RawTarget); Assert.Equal(path, Http1Connection.Path); Assert.Equal(query, Http1Connection.QueryString); // But not the same as the inputs. Assert.NotSame(rawTarget, Http1Connection.RawTarget); Assert.NotSame(path, Http1Connection.Path); Assert.NotSame(query, Http1Connection.QueryString); }
public void InAuthorityForm() { var rawTarget = "example.com:1234"; var path = string.Empty; var query = string.Empty; Http1Connection.Reset(); // RawTarget, Path, QueryString are null after reset Assert.Null(Http1Connection.RawTarget); Assert.Null(Http1Connection.Path); Assert.Null(Http1Connection.QueryString); var ros = new ReadOnlySequence <byte>(Encoding.ASCII.GetBytes($"CONNECT {rawTarget} HTTP/1.1\r\n")); Assert.True(Parser.ParseRequestLine(ParsingHandler, ros, out _, out _)); // Equal the inputs. Assert.Equal(rawTarget, Http1Connection.RawTarget); Assert.Equal(path, Http1Connection.Path); Assert.Equal(query, Http1Connection.QueryString); // But not the same as the inputs. Assert.NotSame(rawTarget, Http1Connection.RawTarget); // Empty strings, so interned and the same. Assert.Same(path, Http1Connection.Path); Assert.Same(query, Http1Connection.QueryString); }
public void Setup() { _memoryPool = KestrelMemoryPool.Create(); var pair = DuplexPipe.CreateConnectionPair(_memoryPool); var serviceContext = new ServiceContext { DateHeaderValueManager = new DateHeaderValueManager(), ServerOptions = new KestrelServerOptions(), Log = new MockTrace(), HttpParser = new HttpParser <Http1ParsingHandler>() }; var http1Connection = new Http1Connection(new Http1ConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), MemoryPool = _memoryPool, Application = pair.Application, Transport = pair.Transport, TimeoutControl = new MockTimeoutControl() }); http1Connection.Reset(); Http1Connection = http1Connection; Pipe = new Pipe(new PipeOptions(_memoryPool)); }
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)); }
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 = new ServiceContext { DateHeaderValueManager = new DateHeaderValueManager(), ServerOptions = new KestrelServerOptions(), Log = new MockTrace(), HttpParser = new HttpParser <Http1ParsingHandler>() }; var http1Connection = new Http1Connection(new HttpConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), MemoryPool = memoryPool, Transport = pair.Transport }); http1Connection.Reset(); _collection = http1Connection; }
public void InitialDictionaryIsEmpty() { using (var memoryPool = new MemoryPool()) { var pair = DuplexPipe.CreateConnectionPair(memoryPool); var http1ConnectionContext = new Http1ConnectionContext { ServiceContext = new TestServiceContext(), ConnectionFeatures = new FeatureCollection(), MemoryPool = memoryPool, Application = pair.Application, Transport = pair.Transport, TimeoutControl = null }; var http1Connection = new Http1Connection(http1ConnectionContext); http1Connection.Reset(); IDictionary <string, StringValues> headers = http1Connection.ResponseHeaders; Assert.Equal(0, headers.Count); Assert.False(headers.IsReadOnly); } }
public void Setup() { var memoryPool = KestrelMemoryPool.Create(); var options = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); var pair = DuplexPipe.CreateConnectionPair(options, options); var serviceContext = new ServiceContext { ServerOptions = new KestrelServerOptions(), HttpParser = NullParser <Http1ParsingHandler> .Instance }; var http1Connection = new Http1Connection(context: new HttpConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), MemoryPool = memoryPool, TimeoutControl = new TimeoutControl(timeoutHandler: null), Transport = pair.Transport }); http1Connection.Reset(); Connection = http1Connection; }
private void ParseDataDrainBuffer() { var awaitable = Pipe.Reader.ReadAsync(); if (!awaitable.IsCompleted) { // No more data return; } var readableBuffer = awaitable.GetResult().Buffer; do { Http1Connection.Reset(); if (!Http1Connection.TakeStartLine(readableBuffer, out var consumed, out var examined)) { ErrorUtilities.ThrowInvalidRequestLine(); } readableBuffer = readableBuffer.Slice(consumed); if (!Http1Connection.TakeMessageHeaders(readableBuffer, out consumed, out examined)) { ErrorUtilities.ThrowInvalidRequestHeaders(); } readableBuffer = readableBuffer.Slice(consumed); }while (readableBuffer.Length > 0); Pipe.Reader.Advance(readableBuffer.End); }
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; } }
public void Setup() { var memoryPool = KestrelMemoryPool.Create(); var options = new PipeOptions(memoryPool, readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false); var pair = DuplexPipe.CreateConnectionPair(options, options); var serviceContext = new ServiceContext { DateHeaderValueManager = _dateHeaderValueManager, ServerOptions = new KestrelServerOptions(), Log = new MockTrace(), HttpParser = new HttpParser <Http1ParsingHandler>() }; var http1Connection = new Http1Connection(new HttpConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), MemoryPool = memoryPool, Transport = pair.Transport }); http1Connection.Reset(); serviceContext.DateHeaderValueManager.OnHeartbeat(DateTimeOffset.UtcNow); _responseHeadersDirect = (HttpResponseHeaders)http1Connection.ResponseHeaders; var context = new DefaultHttpContext(http1Connection); _response = new DefaultHttpResponse(context); switch (Type) { case BenchmarkTypes.ContentLengthNumeric: ContentLengthNumeric(1); break; case BenchmarkTypes.ContentLengthString: ContentLengthString(1); break; case BenchmarkTypes.Plaintext: Plaintext(1); break; case BenchmarkTypes.Common: Common(1); break; case BenchmarkTypes.Unknown: Unknown(1); break; } }
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(), HttpParserFactory = f => new HttpParser <Http1ParsingHandler>() }; var http1Connection = new Http1Connection <object>(application: null, context: new Http1ConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), BufferPool = bufferPool, Application = pair.Application, Transport = pair.Transport }); http1Connection.Reset(); _responseHeadersDirect = (HttpResponseHeaders)http1Connection.ResponseHeaders; var context = new DefaultHttpContext(http1Connection); _response = new DefaultHttpResponse(context); switch (Type) { case BenchmarkTypes.ContentLengthNumeric: ContentLengthNumeric(1); break; case BenchmarkTypes.ContentLengthString: ContentLengthString(1); break; case BenchmarkTypes.Plaintext: Plaintext(1); break; case BenchmarkTypes.Common: Common(1); break; case BenchmarkTypes.Unknown: Unknown(1); break; } }
public void LeadingCrLfAreAllowed(string startOfRequestLine, string httpMethod) { var rawTarget = "http://localhost/path1?q=123&w=xyzw"; Http1Connection.Reset(); // RawTarget, Path, QueryString are null after reset Assert.Null(Http1Connection.RawTarget); Assert.Null(Http1Connection.Path); Assert.Null(Http1Connection.QueryString); var ros = new ReadOnlySequence <byte>(Encoding.ASCII.GetBytes($"{startOfRequestLine}{httpMethod} {rawTarget} HTTP/1.1\r\n")); var reader = new SequenceReader <byte>(ros); Assert.True(Parser.ParseRequestLine(ParsingHandler, ref reader)); }
public void Setup() { var serviceContext = new ServiceContext { HttpParserFactory = f => new HttpParser <Http1ParsingHandler>(), ServerOptions = new KestrelServerOptions() }; var http1ConnectionContext = new Http1ConnectionContext { ServiceContext = serviceContext, ConnectionFeatures = new FeatureCollection(), PipeFactory = new PipeFactory() }; var http1Connection = new Http1Connection <object>(application: null, context: http1ConnectionContext); http1Connection.Reset(); _responseHeadersDirect = (HttpResponseHeaders)http1Connection.ResponseHeaders; var context = new DefaultHttpContext(http1Connection); _response = new DefaultHttpResponse(context); switch (Type) { case BenchmarkTypes.ContentLengthNumeric: ContentLengthNumeric(1); break; case BenchmarkTypes.ContentLengthString: ContentLengthString(1); break; case BenchmarkTypes.Plaintext: Plaintext(1); break; case BenchmarkTypes.Common: Common(1); break; case BenchmarkTypes.Unknown: Unknown(1); break; } }
public void DifferentFormsWorkTogether() { // InOriginForm var rawTarget = "/a%20path%20with%20spaces?q=123&w=xyzw12"; var path = "/a path with spaces"; var query = "?q=123&w=xyzw12"; Http1Connection.Reset(); var ros = new ReadOnlySequence <byte>(Encoding.ASCII.GetBytes($"POST {rawTarget} HTTP/1.1\r\n")); var reader = new SequenceReader <byte>(ros); Assert.True(Parser.ParseRequestLine(ParsingHandler, ref reader)); // Equal the inputs. Assert.Equal(rawTarget, Http1Connection.RawTarget); Assert.Equal(path, Http1Connection.Path); Assert.Equal(query, Http1Connection.QueryString); // But not the same as the inputs. Assert.NotSame(rawTarget, Http1Connection.RawTarget); Assert.NotSame(path, Http1Connection.Path); Assert.NotSame(query, Http1Connection.QueryString); InAuthorityForm(); InOriginForm(); InAbsoluteForm(); InOriginForm(); InAsteriskForm(); InAuthorityForm(); InAsteriskForm(); InAbsoluteForm(); InAuthorityForm(); InAbsoluteForm(); InAsteriskForm(); InAbsoluteForm(); InAuthorityForm(); }