diff --git a/src/Microsoft.AspNetCore.Server.WebListener/FeatureContext.cs b/src/Microsoft.AspNetCore.Server.WebListener/FeatureContext.cs index dd0408237b..ec906fdf37 100644 --- a/src/Microsoft.AspNetCore.Server.WebListener/FeatureContext.cs +++ b/src/Microsoft.AspNetCore.Server.WebListener/FeatureContext.cs @@ -62,6 +62,7 @@ namespace Microsoft.AspNetCore.Server.WebListener private string _query; private string _pathBase; private string _path; + private string _rawTarget; private IPAddress _remoteIpAddress; private IPAddress _localIpAddress; private int? _remotePort; @@ -207,6 +208,19 @@ namespace Microsoft.AspNetCore.Server.WebListener set { _query = value; } } + string IHttpRequestFeature.RawTarget + { + get + { + if (_rawTarget == null) + { + _rawTarget = Request.RawUrl; + } + return _rawTarget; + } + set { _rawTarget = value; } + } + string IHttpRequestFeature.Scheme { get diff --git a/src/Microsoft.Net.Http.Server/RequestProcessing/Request.cs b/src/Microsoft.Net.Http.Server/RequestProcessing/Request.cs index 953556d88a..d2671ae7a2 100644 --- a/src/Microsoft.Net.Http.Server/RequestProcessing/Request.cs +++ b/src/Microsoft.Net.Http.Server/RequestProcessing/Request.cs @@ -296,15 +296,15 @@ namespace Microsoft.Net.Http.Server return _sslStatus != SslStatus.Insecure; } } - /* - internal string RawUrl + + public string RawUrl { get { return _rawUrl; } } - */ + public Version ProtocolVersion { get diff --git a/test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/RequestTests.cs b/test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/RequestTests.cs index 7b574ffca5..08d075089d 100644 --- a/test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/RequestTests.cs +++ b/test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/RequestTests.cs @@ -51,6 +51,7 @@ namespace Microsoft.AspNetCore.Server.WebListener 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); // Server Keys @@ -87,7 +88,7 @@ namespace Microsoft.AspNetCore.Server.WebListener [InlineData("/basepath/", "/basepath", "/basepath", "")] [InlineData("/basepath/", "/basepath/", "/basepath", "/")] [InlineData("/basepath/", "/basepath/subpath", "/basepath", "/subpath")] - [InlineData("/base path/", "/base%20path/sub path", "/base path", "/sub path")] + [InlineData("/base path/", "/base%20path/sub%20path", "/base path", "/sub path")] [InlineData("/base葉path/", "/base%E8%91%89path/sub%E8%91%89path", "/base葉path", "/sub葉path")] [InlineData("/basepath/", "/basepath/sub%2Fpath", "/basepath", "/sub%2Fpath")] public async Task Request_PathSplitting(string pathBase, string requestPath, string expectedPathBase, string expectedPath) @@ -106,6 +107,7 @@ namespace Microsoft.AspNetCore.Server.WebListener Assert.Equal(expectedPath, requestInfo.Path); Assert.Equal(expectedPathBase, requestInfo.PathBase); Assert.Equal(string.Empty, requestInfo.QueryString); + Assert.Equal(requestPath, requestInfo.RawTarget); // Trace identifier Assert.NotNull(requestIdentifierFeature); @@ -132,6 +134,7 @@ namespace Microsoft.AspNetCore.Server.WebListener { var requestInfo = httpContext.Features.Get(); Assert.Equal("/%2F", requestInfo.Path); + Assert.Equal("/%252F", requestInfo.RawTarget); return Task.FromResult(0); })) { @@ -165,6 +168,7 @@ namespace Microsoft.AspNetCore.Server.WebListener { Assert.Equal(expectedPath, requestInfo.Path); Assert.Equal(expectedPathBase, requestInfo.PathBase); + Assert.Equal(requestPath, requestInfo.RawTarget); // Trace identifier Assert.NotNull(requestIdentifierFeature);