Add support for REQUEST_METHOD server variable (#294)

This commit is contained in:
Mikael Mengistu 2018-01-31 10:41:28 -08:00 committed by GitHub
parent aa0395847f
commit f2676babd3
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();
case "REQUEST_FILENAME":
return new RequestFileNameSegment();
case "REQUEST_METHOD":
return new RequestMethodSegment();
case "REQUEST_URI":
return new UrlSegment(uriMatchPart);
default:

View File

@ -27,6 +27,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite
[InlineData("REQUEST_FILENAME", "/foo", UriMatchPart.Path)]
[InlineData("REQUEST_URI", "/foo", UriMatchPart.Path)]
[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)
{
// Arrange and Act
@ -40,6 +41,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite
private RewriteContext CreateTestHttpContext()
{
var context = new DefaultHttpContext();
context.Request.Method = HttpMethods.Get;
context.Request.Scheme = "http";
context.Request.Host = new HostString("example.com");
context.Request.Path = PathString.FromUriComponent("/foo");