Repository: dotnet/aspnetcore
File: src/Servers/HttpSys/test/FunctionalTests/RequestTests.cs (C#)

Code before:

            // Request Keys
            Assert.Equal("GET", requestInfo.Method);
            Assert.Equal(Stream.Null, requestInfo.Body);
            Assert.NotNull(requestInfo.Headers);
            Assert.Equal("http", requestInfo.Scheme);
            Assert.Equal("/basepath", requestInfo.PathBase);
            Assert.Equal("/SomePath", requestInfo.Path);
            Assert.Equal("?SomeQuery", requestInfo.QueryString);
            Assert.Equal("/basepath/SomePath?SomeQuery", requestInfo.RawTarget);
            Assert.Equal("HTTP/1.1", requestInfo.Protocol);

            Assert.False(httpContext.Request.CanHaveBody());
            var connectionInfo = httpContext.Features.Get<IHttpConnectionFeature>();
            Assert.Equal("::1", connectionInfo.RemoteIpAddress.ToString());
            Assert.NotEqual(0, connectionInfo.RemotePort);
            Assert.Equal("::1", connectionInfo.LocalIpAddress.ToString());
            Assert.NotEqual(0, connectionInfo.LocalPort);
            Assert.NotNull(connectionInfo.ConnectionId);

            // Trace identifier
            var requestIdentifierFeature = httpContext.Features.Get<IHttpRequestIdentifierFeature>();
            Assert.NotNull(requestIdentifierFeature);
            Assert.NotNull(requestIdentifierFeature.TraceIdentifier);

            // Note: Response keys are validated in the ResponseTests
        }, options => { }, LoggerFactory))
        {
            string response = await SendRequestAsync(root + "/basepath/SomePath?SomeQuery");
            Assert.Equal(string.Empty, response);
        }
    }

    [ConditionalFact]
    public async Task Request_FieldsCanBeSet_Set()
    {
        string root;
        using (Utilities.CreateHttpServerReturnRoot("/basepath", out root, httpContext =>
        {
            try
            {
                var requestInfo = httpContext.Features.Get<IHttpRequestFeature>();

                // Request Keys
                requestInfo.Method = "TEST";
                Assert.Equal("TEST", requestInfo.Method);
                requestInfo.Body = new MemoryStream();
                Assert.IsType<MemoryStream>(requestInfo.Body);
                var customHeaders = new HeaderCollection();
                requestInfo.Headers = customHeaders;
                Assert.Same(customHeaders, requestInfo.Headers);

Review comment (suggestion):
```suggestion
            // Note: Response keys are validated in the ResponseTests
            
            return Task.CompletedTask;
```

Code after:

            // Request Keys
            Assert.Equal("GET", requestInfo.Method);
            Assert.Equal(Stream.Null, requestInfo.Body);
            Assert.NotNull(requestInfo.Headers);
            Assert.Equal("http", requestInfo.Scheme);
            Assert.Equal("/basepath", requestInfo.PathBase);
            Assert.Equal("/SomePath", requestInfo.Path);
            Assert.Equal("?SomeQuery", requestInfo.QueryString);
            Assert.Equal("/basepath/SomePath?SomeQuery", requestInfo.RawTarget);
            Assert.Equal("HTTP/1.1", requestInfo.Protocol);

            Assert.False(httpContext.Request.CanHaveBody());
            var connectionInfo = httpContext.Features.Get<IHttpConnectionFeature>();
            Assert.Equal("::1", connectionInfo.RemoteIpAddress.ToString());
            Assert.NotEqual(0, connectionInfo.RemotePort);
            Assert.Equal("::1", connectionInfo.LocalIpAddress.ToString());
            Assert.NotEqual(0, connectionInfo.LocalPort);
            Assert.NotNull(connectionInfo.ConnectionId);

            // Trace identifier
            var requestIdentifierFeature = httpContext.Features.Get<IHttpRequestIdentifierFeature>();
            Assert.NotNull(requestIdentifierFeature);
            Assert.NotNull(requestIdentifierFeature.TraceIdentifier);

            // Note: Response keys are validated in the ResponseTests
            
            return Task.CompletedTask;
        }, options => { }, LoggerFactory))
        {
            string response = await SendRequestAsync(root + "/basepath/SomePath?SomeQuery");
            Assert.Equal(string.Empty, response);
        }
    }

    [ConditionalFact]
    public async Task Request_FieldsCanBeSet_Set()
    {
        string root;
        using (Utilities.CreateHttpServerReturnRoot("/basepath", out root, httpContext =>
        {
            try
            {
                var requestInfo = httpContext.Features.Get<IHttpRequestFeature>();

                // Request Keys
                requestInfo.Method = "TEST";
                Assert.Equal("TEST", requestInfo.Method);
                requestInfo.Body = new MemoryStream();
                Assert.IsType<MemoryStream>(requestInfo.Body);
                var customHeaders = new HeaderCollection();