Merge release/2.1 - Add support for REQUEST_METHOD server variable

This commit is contained in:
Mikael Mengistu 2018-01-31 11:47:08 -08:00 committed by GitHub
parent dd03838728
commit b85d69c882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -60,6 +60,8 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite
return new RemotePortSegment(); return new RemotePortSegment();
case "REQUEST_FILENAME": case "REQUEST_FILENAME":
return new RequestFileNameSegment(); return new RequestFileNameSegment();
case "REQUEST_METHOD":
return new RequestMethodSegment();
case "REQUEST_URI": case "REQUEST_URI":
return new UrlSegment(uriMatchPart); return new UrlSegment(uriMatchPart);
default: default:

View File

@ -27,6 +27,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite
[InlineData("REQUEST_FILENAME", "/foo", UriMatchPart.Path)] [InlineData("REQUEST_FILENAME", "/foo", UriMatchPart.Path)]
[InlineData("REQUEST_URI", "/foo", UriMatchPart.Path)] [InlineData("REQUEST_URI", "/foo", UriMatchPart.Path)]
[InlineData("REQUEST_URI", "http://example.com/foo?bar=1", UriMatchPart.Full)] [InlineData("REQUEST_URI", "http://example.com/foo?bar=1", UriMatchPart.Full)]
[InlineData("REQUEST_METHOD", "GET", UriMatchPart.Full)]
public void CheckServerVariableParsingAndApplication(string variable, string expected, UriMatchPart uriMatchPart) public void CheckServerVariableParsingAndApplication(string variable, string expected, UriMatchPart uriMatchPart)
{ {
// Arrange and Act // Arrange and Act
@ -40,6 +41,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite
private RewriteContext CreateTestHttpContext() private RewriteContext CreateTestHttpContext()
{ {
var context = new DefaultHttpContext(); var context = new DefaultHttpContext();
context.Request.Method = HttpMethods.Get;
context.Request.Scheme = "http"; context.Request.Scheme = "http";
context.Request.Host = new HostString("example.com"); context.Request.Host = new HostString("example.com");
context.Request.Path = PathString.FromUriComponent("/foo"); context.Request.Path = PathString.FromUriComponent("/foo");