Implement IHttpRequestFeature.RawTarget.
This commit is contained in:
parent
f5bd95b93f
commit
55d2ef02b1
|
|
@ -62,6 +62,7 @@ namespace Microsoft.AspNetCore.Server.WebListener
|
||||||
private string _query;
|
private string _query;
|
||||||
private string _pathBase;
|
private string _pathBase;
|
||||||
private string _path;
|
private string _path;
|
||||||
|
private string _rawTarget;
|
||||||
private IPAddress _remoteIpAddress;
|
private IPAddress _remoteIpAddress;
|
||||||
private IPAddress _localIpAddress;
|
private IPAddress _localIpAddress;
|
||||||
private int? _remotePort;
|
private int? _remotePort;
|
||||||
|
|
@ -207,6 +208,19 @@ namespace Microsoft.AspNetCore.Server.WebListener
|
||||||
set { _query = value; }
|
set { _query = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string IHttpRequestFeature.RawTarget
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_rawTarget == null)
|
||||||
|
{
|
||||||
|
_rawTarget = Request.RawUrl;
|
||||||
|
}
|
||||||
|
return _rawTarget;
|
||||||
|
}
|
||||||
|
set { _rawTarget = value; }
|
||||||
|
}
|
||||||
|
|
||||||
string IHttpRequestFeature.Scheme
|
string IHttpRequestFeature.Scheme
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
|
|
@ -296,15 +296,15 @@ namespace Microsoft.Net.Http.Server
|
||||||
return _sslStatus != SslStatus.Insecure;
|
return _sslStatus != SslStatus.Insecure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
internal string RawUrl
|
public string RawUrl
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _rawUrl;
|
return _rawUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
public Version ProtocolVersion
|
public Version ProtocolVersion
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ namespace Microsoft.AspNetCore.Server.WebListener
|
||||||
Assert.Equal("/basepath", requestInfo.PathBase);
|
Assert.Equal("/basepath", requestInfo.PathBase);
|
||||||
Assert.Equal("/SomePath", requestInfo.Path);
|
Assert.Equal("/SomePath", requestInfo.Path);
|
||||||
Assert.Equal("?SomeQuery", requestInfo.QueryString);
|
Assert.Equal("?SomeQuery", requestInfo.QueryString);
|
||||||
|
Assert.Equal("/basepath/SomePath?SomeQuery", requestInfo.RawTarget);
|
||||||
Assert.Equal("HTTP/1.1", requestInfo.Protocol);
|
Assert.Equal("HTTP/1.1", requestInfo.Protocol);
|
||||||
|
|
||||||
// Server Keys
|
// Server Keys
|
||||||
|
|
@ -87,7 +88,7 @@ namespace Microsoft.AspNetCore.Server.WebListener
|
||||||
[InlineData("/basepath/", "/basepath", "/basepath", "")]
|
[InlineData("/basepath/", "/basepath", "/basepath", "")]
|
||||||
[InlineData("/basepath/", "/basepath/", "/basepath", "/")]
|
[InlineData("/basepath/", "/basepath/", "/basepath", "/")]
|
||||||
[InlineData("/basepath/", "/basepath/subpath", "/basepath", "/subpath")]
|
[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("/base葉path/", "/base%E8%91%89path/sub%E8%91%89path", "/base葉path", "/sub葉path")]
|
||||||
[InlineData("/basepath/", "/basepath/sub%2Fpath", "/basepath", "/sub%2Fpath")]
|
[InlineData("/basepath/", "/basepath/sub%2Fpath", "/basepath", "/sub%2Fpath")]
|
||||||
public async Task Request_PathSplitting(string pathBase, string requestPath, string expectedPathBase, string expectedPath)
|
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(expectedPath, requestInfo.Path);
|
||||||
Assert.Equal(expectedPathBase, requestInfo.PathBase);
|
Assert.Equal(expectedPathBase, requestInfo.PathBase);
|
||||||
Assert.Equal(string.Empty, requestInfo.QueryString);
|
Assert.Equal(string.Empty, requestInfo.QueryString);
|
||||||
|
Assert.Equal(requestPath, requestInfo.RawTarget);
|
||||||
|
|
||||||
// Trace identifier
|
// Trace identifier
|
||||||
Assert.NotNull(requestIdentifierFeature);
|
Assert.NotNull(requestIdentifierFeature);
|
||||||
|
|
@ -132,6 +134,7 @@ namespace Microsoft.AspNetCore.Server.WebListener
|
||||||
{
|
{
|
||||||
var requestInfo = httpContext.Features.Get<IHttpRequestFeature>();
|
var requestInfo = httpContext.Features.Get<IHttpRequestFeature>();
|
||||||
Assert.Equal("/%2F", requestInfo.Path);
|
Assert.Equal("/%2F", requestInfo.Path);
|
||||||
|
Assert.Equal("/%252F", requestInfo.RawTarget);
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
|
|
@ -165,6 +168,7 @@ namespace Microsoft.AspNetCore.Server.WebListener
|
||||||
{
|
{
|
||||||
Assert.Equal(expectedPath, requestInfo.Path);
|
Assert.Equal(expectedPath, requestInfo.Path);
|
||||||
Assert.Equal(expectedPathBase, requestInfo.PathBase);
|
Assert.Equal(expectedPathBase, requestInfo.PathBase);
|
||||||
|
Assert.Equal(requestPath, requestInfo.RawTarget);
|
||||||
|
|
||||||
// Trace identifier
|
// Trace identifier
|
||||||
Assert.NotNull(requestIdentifierFeature);
|
Assert.NotNull(requestIdentifierFeature);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue