From a5ff9d800374c60a92e8b1722166f41a6f7607bd Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 6 Sep 2016 10:51:19 -0700 Subject: [PATCH] Add 'Apache' and 'IIS' to internal namespaces and classes --- .gitignore | 5 ++++- .../ApacheModRewriteOptionsExtensions.cs | 2 +- .../IISUrlRewriteOptionsExtensions.cs | 2 +- .../ApacheModRewriteRule.cs} | 6 +++--- .../ConditionPatternParser.cs | 2 +- .../ConditionType.cs | 2 +- .../FileParser.cs | 2 +- .../FlagParser.cs | 2 +- .../{ModRewrite => ApacheModRewrite}/FlagType.cs | 2 +- .../{ModRewrite => ApacheModRewrite}/Flags.cs | 2 +- .../OperationType.cs | 2 +- .../ParsedModRewriteCondition.cs | 2 +- .../RuleBuilder.cs | 6 +++--- .../RuleRegexParser.cs | 2 +- .../SegmentType.cs | 2 +- .../ServerVariables.cs | 2 +- .../TestStringParser.cs | 2 +- .../Tokenizer.cs | 2 +- .../Internal/{CodeRules => }/DelegateRule.cs | 2 +- .../{UrlRewrite => IISUrlRewrite}/ActionType.cs | 2 +- .../IISUrlRewriteRule.cs} | 6 +++--- .../{UrlRewrite => IISUrlRewrite}/InputParser.cs | 2 +- .../LogicalGrouping.cs | 2 +- .../{UrlRewrite => IISUrlRewrite}/MatchType.cs | 2 +- .../PatternSyntax.cs | 2 +- .../RedirectType.cs | 2 +- .../{UrlRewrite => IISUrlRewrite}/RewriteTags.cs | 2 +- .../ServerVariables.cs | 2 +- .../UrlRewriteFileParser.cs | 12 ++++++------ .../UrlRewriteRuleBuilder.cs | 11 +++++------ .../Internal/{CodeRules => }/RedirectRule.cs | 4 ++-- .../{CodeRules => }/RedirectToHttpsRule.cs | 2 +- .../Internal/{CodeRules => }/RewriteRule.cs | 2 +- .../Internal/UrlActions/ChangeCookieAction.cs | 1 - .../UrlActions/ChangeEnvironmentAction.cs | 1 - .../Internal/UrlActions/RedirectAction.cs | 2 -- .../Internal/UrlActions/RewriteAction.cs | 6 +++--- .../RewriteMiddleware.cs | 10 ++++++---- .../RewriteOptionsExtensions.cs | 6 ++---- .../ConditionPatternParserTest.cs | 2 +- .../FlagParserTest.cs | 2 +- .../FormatExceptionTests.cs | 2 +- .../ModRewriteMiddlewareTest.cs | 0 .../RewriteTokenizerTest.cs | 2 +- .../RuleRegexParserTest.cs | 2 +- .../TestStringParserTests.cs | 2 +- .../FileParserTests.cs | 16 ++++++++-------- .../FormatExceptionHandlingTests.cs | 2 +- .../InputParserTests.cs | 2 +- .../MiddleWareTests.cs | 0 .../ServerVariableTests.cs | 2 +- .../UrlRewriteApplicationTests.cs | 2 +- .../{CodeRules => }/MiddlewareTests.cs | 0 53 files changed, 81 insertions(+), 83 deletions(-) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewriteRule.cs => ApacheModRewrite/ApacheModRewriteRule.cs} (88%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/ConditionPatternParser.cs (99%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/ConditionType.cs (81%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/FileParser.cs (98%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/FlagParser.cs (98%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/FlagType.cs (90%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/Flags.cs (96%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/OperationType.cs (87%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/ParsedModRewriteCondition.cs (92%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/RuleBuilder.cs (98%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/RuleRegexParser.cs (92%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/SegmentType.cs (82%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/ServerVariables.cs (98%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/TestStringParser.cs (99%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{ModRewrite => ApacheModRewrite}/Tokenizer.cs (98%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{CodeRules => }/DelegateRule.cs (89%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/ActionType.cs (83%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewriteRule.cs => IISUrlRewrite/IISUrlRewriteRule.cs} (93%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/InputParser.cs (99%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/LogicalGrouping.cs (80%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/MatchType.cs (81%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/PatternSyntax.cs (81%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/RedirectType.cs (83%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/RewriteTags.cs (95%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/ServerVariables.cs (97%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/UrlRewriteFileParser.cs (96%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{UrlRewrite => IISUrlRewrite}/UrlRewriteRuleBuilder.cs (95%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{CodeRules => }/RedirectRule.cs (96%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{CodeRules => }/RedirectToHttpsRule.cs (95%) rename src/Microsoft.AspNetCore.Rewrite/Internal/{CodeRules => }/RewriteRule.cs (98%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{ModRewrite => ApacheModRewrite}/ConditionPatternParserTest.cs (99%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{ModRewrite => ApacheModRewrite}/FlagParserTest.cs (98%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{ModRewrite => ApacheModRewrite}/FormatExceptionTests.cs (97%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{ModRewrite => ApacheModRewrite}/ModRewriteMiddlewareTest.cs (100%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{ModRewrite => ApacheModRewrite}/RewriteTokenizerTest.cs (98%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{ModRewrite => ApacheModRewrite}/RuleRegexParserTest.cs (93%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{ModRewrite => ApacheModRewrite}/TestStringParserTests.cs (98%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{UrlRewrite => IISUrlRewrite}/FileParserTests.cs (92%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{UrlRewrite => IISUrlRewrite}/FormatExceptionHandlingTests.cs (98%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{UrlRewrite => IISUrlRewrite}/InputParserTests.cs (98%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{UrlRewrite => IISUrlRewrite}/MiddleWareTests.cs (100%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{UrlRewrite => IISUrlRewrite}/ServerVariableTests.cs (97%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{UrlRewrite => IISUrlRewrite}/UrlRewriteApplicationTests.cs (96%) rename test/Microsoft.AspNetCore.Rewrite.Tests/{CodeRules => }/MiddlewareTests.cs (100%) diff --git a/.gitignore b/.gitignore index 4ddb21ac5f..abc642dc8d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,7 @@ project.lock.json *.ipch .vs/ .build/ -.testPublish/ \ No newline at end of file +.testPublish/ +.idea/ +.vscode/ + diff --git a/src/Microsoft.AspNetCore.Rewrite/ApacheModRewriteOptionsExtensions.cs b/src/Microsoft.AspNetCore.Rewrite/ApacheModRewriteOptionsExtensions.cs index e237c7610c..99aa31ada4 100644 --- a/src/Microsoft.AspNetCore.Rewrite/ApacheModRewriteOptionsExtensions.cs +++ b/src/Microsoft.AspNetCore.Rewrite/ApacheModRewriteOptionsExtensions.cs @@ -4,7 +4,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Rewrite.Internal.ModRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite; namespace Microsoft.AspNetCore.Rewrite { diff --git a/src/Microsoft.AspNetCore.Rewrite/IISUrlRewriteOptionsExtensions.cs b/src/Microsoft.AspNetCore.Rewrite/IISUrlRewriteOptionsExtensions.cs index 21658e5649..05d49b9ac8 100644 --- a/src/Microsoft.AspNetCore.Rewrite/IISUrlRewriteOptionsExtensions.cs +++ b/src/Microsoft.AspNetCore.Rewrite/IISUrlRewriteOptionsExtensions.cs @@ -4,7 +4,7 @@ using System; using System.IO; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite; namespace Microsoft.AspNetCore.Rewrite { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewriteRule.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ApacheModRewriteRule.cs similarity index 88% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewriteRule.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ApacheModRewriteRule.cs index 11daadce68..6fb201e12f 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewriteRule.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ApacheModRewriteRule.cs @@ -4,15 +4,15 @@ using System.Collections.Generic; using Microsoft.AspNetCore.Rewrite.Logging; -namespace Microsoft.AspNetCore.Rewrite.Internal +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { - public class ModRewriteRule : Rule + public class ApacheModRewriteRule : Rule { public UrlMatch InitialMatch { get; } public IList Conditions { get; } public IList Actions { get; } - public ModRewriteRule(UrlMatch initialMatch, IList conditions, IList urlActions) + public ApacheModRewriteRule(UrlMatch initialMatch, IList conditions, IList urlActions) { Conditions = conditions; InitialMatch = initialMatch; diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ConditionPatternParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionPatternParser.cs similarity index 99% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ConditionPatternParser.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionPatternParser.cs index fadd570f97..9523b897df 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ConditionPatternParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionPatternParser.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { /// /// Parses the "CondPattern" portion of the RewriteCond. diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ConditionType.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionType.cs similarity index 81% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ConditionType.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionType.cs index f8f6818979..0624bbfede 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ConditionType.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionType.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { public enum ConditionType { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/FileParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/FileParser.cs similarity index 98% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/FileParser.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/FileParser.cs index 5eb4bb6d76..c2525f409f 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/FileParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/FileParser.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.IO; -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { public class FileParser { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/FlagParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/FlagParser.cs similarity index 98% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/FlagParser.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/FlagParser.cs index 0888f614ab..b3e957a5c7 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/FlagParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/FlagParser.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { public class FlagParser { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/FlagType.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/FlagType.cs similarity index 90% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/FlagType.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/FlagType.cs index 85919a7a41..67ea9875bf 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/FlagType.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/FlagType.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { public enum FlagType { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/Flags.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/Flags.cs similarity index 96% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/Flags.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/Flags.cs index 5df8cc09be..0f5fac2c25 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/Flags.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/Flags.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { // For more information of flags, and what flags we currently support: // https://github.com/aspnet/BasicMiddleware/issues/66 diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/OperationType.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/OperationType.cs similarity index 87% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/OperationType.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/OperationType.cs index 4019c1cc11..1f22902d57 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/OperationType.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/OperationType.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { public enum OperationType { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ParsedModRewriteCondition.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ParsedModRewriteCondition.cs similarity index 92% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ParsedModRewriteCondition.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ParsedModRewriteCondition.cs index e854343fe5..759ab51307 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ParsedModRewriteCondition.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ParsedModRewriteCondition.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { public class ParsedModRewriteInput { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/RuleBuilder.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleBuilder.cs similarity index 98% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/RuleBuilder.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleBuilder.cs index c2dcdf2128..bec58de1bc 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/RuleBuilder.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleBuilder.cs @@ -7,7 +7,7 @@ using System.Text.RegularExpressions; using Microsoft.AspNetCore.Rewrite.Internal.UrlActions; using Microsoft.AspNetCore.Rewrite.Internal.UrlMatches; -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { public class RuleBuilder { @@ -17,13 +17,13 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite private readonly TimeSpan RegexTimeout = TimeSpan.FromMilliseconds(1); - public ModRewriteRule Build() + public ApacheModRewriteRule Build() { if (_actions.Count == 0 || _match == null) { throw new InvalidOperationException("Cannot create ModRewriteRule without action and match"); } - return new ModRewriteRule(_match, _conditions, _actions); + return new ApacheModRewriteRule(_match, _conditions, _actions); } public void AddRule(string rule) diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/RuleRegexParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleRegexParser.cs similarity index 92% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/RuleRegexParser.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleRegexParser.cs index e9cbb8a36c..e8c0eeec69 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/RuleRegexParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleRegexParser.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { public class RuleRegexParser { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/SegmentType.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/SegmentType.cs similarity index 82% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/SegmentType.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/SegmentType.cs index 2e86cde344..ee47c978cf 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/SegmentType.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/SegmentType.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { public enum SegmentType { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ServerVariables.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ServerVariables.cs similarity index 98% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ServerVariables.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ServerVariables.cs index 7d295f84f8..eb3e73f895 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/ServerVariables.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ServerVariables.cs @@ -5,7 +5,7 @@ using System; using Microsoft.AspNetCore.Rewrite.Internal.PatternSegments; using Microsoft.Net.Http.Headers; -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { /// /// mod_rewrite lookups for specific string constants. diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/TestStringParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/TestStringParser.cs similarity index 99% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/TestStringParser.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/TestStringParser.cs index a87d9b1ed6..151a9c7c10 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/TestStringParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/TestStringParser.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using Microsoft.AspNetCore.Rewrite.Internal.PatternSegments; -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { /// /// Parses the TestString segment of the mod_rewrite condition. diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/Tokenizer.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/Tokenizer.cs similarity index 98% rename from src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/Tokenizer.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/Tokenizer.cs index 1ecabd093d..b9d19bd8c7 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ModRewrite/Tokenizer.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/Tokenizer.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; -namespace Microsoft.AspNetCore.Rewrite.Internal.ModRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { /// /// Tokenizes a mod_rewrite rule, delimited by spaces. diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/DelegateRule.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/DelegateRule.cs similarity index 89% rename from src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/DelegateRule.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/DelegateRule.cs index 869e773c37..60a670a7fc 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/DelegateRule.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/DelegateRule.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNetCore.Rewrite.Internal.CodeRules +namespace Microsoft.AspNetCore.Rewrite.Internal { public class DelegateRule : Rule { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/ActionType.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ActionType.cs similarity index 83% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/ActionType.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ActionType.cs index 877871073b..75bda6efa7 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/ActionType.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ActionType.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public enum ActionType { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewriteRule.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/IISUrlRewriteRule.cs similarity index 93% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewriteRule.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/IISUrlRewriteRule.cs index 6923445187..ba6b718cd3 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewriteRule.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/IISUrlRewriteRule.cs @@ -5,16 +5,16 @@ using System.Collections.Generic; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Rewrite.Logging; -namespace Microsoft.AspNetCore.Rewrite.Internal +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { - public class UrlRewriteRule : Rule + public class IISUrlRewriteRule : Rule { public string Name { get; } public UrlMatch InitialMatch { get; } public IList Conditions { get; } public UrlAction Action { get; } - public UrlRewriteRule(string name, + public IISUrlRewriteRule(string name, UrlMatch initialMatch, IList conditions, UrlAction action) diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/InputParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/InputParser.cs similarity index 99% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/InputParser.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/InputParser.cs index 218a380dff..e471248868 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/InputParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/InputParser.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using Microsoft.AspNetCore.Rewrite.Internal.PatternSegments; -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public class InputParser { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/LogicalGrouping.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/LogicalGrouping.cs similarity index 80% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/LogicalGrouping.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/LogicalGrouping.cs index 275d317b65..85dc616e89 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/LogicalGrouping.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/LogicalGrouping.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public enum LogicalGrouping { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/MatchType.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/MatchType.cs similarity index 81% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/MatchType.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/MatchType.cs index cfb763dcfb..4f02dc48ce 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/MatchType.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/MatchType.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public enum MatchType { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/PatternSyntax.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/PatternSyntax.cs similarity index 81% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/PatternSyntax.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/PatternSyntax.cs index c32b04f844..b068016e72 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/PatternSyntax.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/PatternSyntax.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public enum PatternSyntax { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/RedirectType.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/RedirectType.cs similarity index 83% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/RedirectType.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/RedirectType.cs index ce52d9d408..2221d5412b 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/RedirectType.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/RedirectType.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public enum RedirectType { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/RewriteTags.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/RewriteTags.cs similarity index 95% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/RewriteTags.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/RewriteTags.cs index 2421fe2eb5..420e8e461d 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/RewriteTags.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/RewriteTags.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public static class RewriteTags { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/ServerVariables.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ServerVariables.cs similarity index 97% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/ServerVariables.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ServerVariables.cs index acb996f77a..35112b78bb 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/ServerVariables.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/ServerVariables.cs @@ -5,7 +5,7 @@ using System; using Microsoft.AspNetCore.Rewrite.Internal.PatternSegments; using Microsoft.Net.Http.Headers; -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public static class ServerVariables { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/UrlRewriteFileParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteFileParser.cs similarity index 96% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/UrlRewriteFileParser.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteFileParser.cs index d3d071585c..3a2f603c07 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/UrlRewriteFileParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteFileParser.cs @@ -8,20 +8,20 @@ using System.Linq; using System.Xml; using System.Xml.Linq; -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public class UrlRewriteFileParser { private readonly InputParser _inputParser = new InputParser(); - public IList Parse(TextReader reader) + public IList Parse(TextReader reader) { var xmlDoc = XDocument.Load(reader, LoadOptions.SetLineInfo); var xmlRoot = xmlDoc.Descendants(RewriteTags.Rewrite).FirstOrDefault(); if (xmlRoot != null) { - var result = new List(); + var result = new List(); // TODO Global rules are currently not treated differently than normal rules, fix. // See: https://github.com/aspnet/BasicMiddleware/issues/59 ParseRules(xmlRoot.Descendants(RewriteTags.GlobalRules).FirstOrDefault(), result); @@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite return null; } - private void ParseRules(XElement rules, IList result) + private void ParseRules(XElement rules, IList result) { if (rules == null) { @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite { var builder = new UrlRewriteRuleBuilder(); ParseRuleAttributes(rule, builder); - + if (builder.Enabled) { result.Add(builder.Build()); @@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite LogicalGrouping grouping; if (!Enum.TryParse(conditions.Attribute(RewriteTags.MatchType)?.Value, out grouping)) { - grouping = LogicalGrouping.MatchAll; + grouping = LogicalGrouping.MatchAll; } bool trackingAllCaptures; diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/UrlRewriteRuleBuilder.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteRuleBuilder.cs similarity index 95% rename from src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/UrlRewriteRuleBuilder.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteRuleBuilder.cs index cf9467ad9e..b4bf4260c4 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlRewrite/UrlRewriteRuleBuilder.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteRuleBuilder.cs @@ -5,11 +5,10 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Rewrite.Internal.ModRewrite; using Microsoft.AspNetCore.Rewrite.Internal.UrlActions; using Microsoft.AspNetCore.Rewrite.Internal.UrlMatches; -namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite +namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite { public class UrlRewriteRuleBuilder { @@ -23,14 +22,14 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite private UrlAction _action; private bool _matchAny; - public UrlRewriteRule Build() + public IISUrlRewriteRule Build() { if (_initialMatch == null || _action == null) { throw new InvalidOperationException("Cannot create UrlRewriteRule without action and match"); } - return new UrlRewriteRule(Name, _initialMatch, _conditions, _action); + return new IISUrlRewriteRule(Name, _initialMatch, _conditions, _action); } public void AddUrlAction( @@ -107,11 +106,11 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite } var regex = new Regex( - pattern, + pattern, ignoreCase ? RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.IgnoreCase : RegexOptions.CultureInvariant | RegexOptions.Compiled, RegexTimeout); - + _conditions.Add(new Condition { Input = input, Match = new RegexMatch(regex, negate), OrNext = _matchAny }); break; } diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/RedirectRule.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/RedirectRule.cs similarity index 96% rename from src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/RedirectRule.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/RedirectRule.cs index 2a68eb1b3c..449ae293a4 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/RedirectRule.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/RedirectRule.cs @@ -6,7 +6,7 @@ using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; using Microsoft.Net.Http.Headers; -namespace Microsoft.AspNetCore.Rewrite.Internal.CodeRules +namespace Microsoft.AspNetCore.Rewrite.Internal { public class RedirectRule : Rule { @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.CodeRules var query = context.HttpContext.Request.QueryString.Add( QueryString.FromUriComponent( newPath.Substring(split))); - // not using the HttpContext.Response.redirect here because status codes may be 301, 302, 307, 308 + // not using the HttpContext.Response.redirect here because status codes may be 301, 302, 307, 308 response.Headers[HeaderNames.Location] = pathBase + newPath.Substring(0, split) + query; } else diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/RedirectToHttpsRule.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/RedirectToHttpsRule.cs similarity index 95% rename from src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/RedirectToHttpsRule.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/RedirectToHttpsRule.cs index a4b99de157..139b70d3e4 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/RedirectToHttpsRule.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/RedirectToHttpsRule.cs @@ -4,7 +4,7 @@ using System.Text; using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNetCore.Rewrite.Internal.CodeRules +namespace Microsoft.AspNetCore.Rewrite.Internal { public class RedirectToHttpsRule : Rule { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/RewriteRule.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/RewriteRule.cs similarity index 98% rename from src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/RewriteRule.cs rename to src/Microsoft.AspNetCore.Rewrite/Internal/RewriteRule.cs index d930a2b279..9bacf4963d 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/CodeRules/RewriteRule.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/RewriteRule.cs @@ -6,7 +6,7 @@ using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; -namespace Microsoft.AspNetCore.Rewrite.Internal.CodeRules +namespace Microsoft.AspNetCore.Rewrite.Internal { public class RewriteRule : Rule { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeCookieAction.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeCookieAction.cs index 5bc7d0ee87..3bdd95e990 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeCookieAction.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeCookieAction.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Rewrite.Internal.UrlActions { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeEnvironmentAction.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeEnvironmentAction.cs index 9854155678..c0b314a643 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeEnvironmentAction.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeEnvironmentAction.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Rewrite.Internal.UrlActions { diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/RedirectAction.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/RedirectAction.cs index b295804064..4d85531c87 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/RedirectAction.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/RedirectAction.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Rewrite.Internal.PatternSegments; using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Rewrite.Internal.UrlActions diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/RewriteAction.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/RewriteAction.cs index 92a4b9c070..74264a9079 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/RewriteAction.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/RewriteAction.cs @@ -33,14 +33,14 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.UrlActions public RewriteAction( RuleTermination result, Pattern pattern, - bool queryStringAppend): - this (result, + bool queryStringAppend) : + this(result, pattern, queryStringAppend, queryStringDelete: false, escapeBackReferences: false) { - + } public override void ApplyAction(RewriteContext context, MatchResults ruleMatch, MatchResults condMatch) diff --git a/src/Microsoft.AspNetCore.Rewrite/RewriteMiddleware.cs b/src/Microsoft.AspNetCore.Rewrite/RewriteMiddleware.cs index d02a28a6db..032b2250ee 100644 --- a/src/Microsoft.AspNetCore.Rewrite/RewriteMiddleware.cs +++ b/src/Microsoft.AspNetCore.Rewrite/RewriteMiddleware.cs @@ -32,9 +32,9 @@ namespace Microsoft.AspNetCore.Rewrite /// The Logger Factory. /// The middleware options, containing the rules to apply. public RewriteMiddleware( - RequestDelegate next, - IHostingEnvironment hostingEnvironment, - ILoggerFactory loggerFactory, + RequestDelegate next, + IHostingEnvironment hostingEnvironment, + ILoggerFactory loggerFactory, RewriteOptions options) { if (next == null) @@ -64,7 +64,9 @@ namespace Microsoft.AspNetCore.Rewrite { throw new ArgumentNullException(nameof(context)); } - var rewriteContext = new RewriteContext { + + var rewriteContext = new RewriteContext + { HttpContext = context, StaticFileProvider = _fileProvider, Logger = _logger, diff --git a/src/Microsoft.AspNetCore.Rewrite/RewriteOptionsExtensions.cs b/src/Microsoft.AspNetCore.Rewrite/RewriteOptionsExtensions.cs index 4d89e13d3c..906c107952 100644 --- a/src/Microsoft.AspNetCore.Rewrite/RewriteOptionsExtensions.cs +++ b/src/Microsoft.AspNetCore.Rewrite/RewriteOptionsExtensions.cs @@ -3,13 +3,11 @@ using System; using Microsoft.AspNetCore.Rewrite.Internal; -using Microsoft.AspNetCore.Rewrite.Internal.CodeRules; -using Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite; namespace Microsoft.AspNetCore.Rewrite { /// - /// The builder to a list of rules for and + /// The builder to a list of rules for and /// public static class RewriteOptionsExtensions { @@ -90,7 +88,7 @@ namespace Microsoft.AspNetCore.Rewrite } /// - /// Redirect a request to https if the incoming request is http, with returning a 301 + /// Redirect a request to https if the incoming request is http, with returning a 301 /// status code for permanently redirected. /// /// diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/ConditionPatternParserTest.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/ConditionPatternParserTest.cs similarity index 99% rename from test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/ConditionPatternParserTest.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/ConditionPatternParserTest.cs index 7d67317e1b..99a58c0b88 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/ConditionPatternParserTest.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/ConditionPatternParserTest.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Rewrite.Internal.ModRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite; using Xunit; namespace Microsoft.AspNetCore.Rewrite.Tests.ModRewrite diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/FlagParserTest.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/FlagParserTest.cs similarity index 98% rename from test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/FlagParserTest.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/FlagParserTest.cs index d788fa25b9..8270bc07cc 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/FlagParserTest.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/FlagParserTest.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.AspNetCore.Rewrite.Internal.ModRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite; using Xunit; namespace Microsoft.AspNetCore.Rewrite.Tests.ModRewrite diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/FormatExceptionTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/FormatExceptionTests.cs similarity index 97% rename from test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/FormatExceptionTests.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/FormatExceptionTests.cs index 6c0913565a..acf46b3765 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/FormatExceptionTests.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/FormatExceptionTests.cs @@ -3,7 +3,7 @@ using System; using System.IO; -using Microsoft.AspNetCore.Rewrite.Internal.ModRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite; using Xunit; namespace Microsoft.AspNetCore.Rewrite.Tests.ModRewrite diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/ModRewriteMiddlewareTest.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/ModRewriteMiddlewareTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/ModRewriteMiddlewareTest.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/ModRewriteMiddlewareTest.cs diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/RewriteTokenizerTest.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/RewriteTokenizerTest.cs similarity index 98% rename from test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/RewriteTokenizerTest.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/RewriteTokenizerTest.cs index c3f4ba28ff..98e556df50 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/RewriteTokenizerTest.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/RewriteTokenizerTest.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using Microsoft.AspNetCore.Rewrite.Internal.ModRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite; using Xunit; namespace Microsoft.AspNetCore.Rewrite.Tests.ModRewrite diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/RuleRegexParserTest.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/RuleRegexParserTest.cs similarity index 93% rename from test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/RuleRegexParserTest.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/RuleRegexParserTest.cs index 16a7954700..fefc5f2b2e 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/RuleRegexParserTest.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/RuleRegexParserTest.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Rewrite.Internal.ModRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite; using Xunit; namespace Microsoft.AspNetCore.Rewrite.Tests.ModRewrite diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/TestStringParserTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/TestStringParserTests.cs similarity index 98% rename from test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/TestStringParserTests.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/TestStringParserTests.cs index b07dcdd7c6..917e628040 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/ModRewrite/TestStringParserTests.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/TestStringParserTests.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using Microsoft.AspNetCore.Rewrite.Internal; -using Microsoft.AspNetCore.Rewrite.Internal.ModRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite; using Microsoft.AspNetCore.Rewrite.Internal.PatternSegments; using Xunit; diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/FileParserTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/FileParserTests.cs similarity index 92% rename from test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/FileParserTests.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/FileParserTests.cs index 4512d9328b..afa76bb395 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/FileParserTests.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/FileParserTests.cs @@ -5,10 +5,10 @@ using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Rewrite.Internal; -using Microsoft.AspNetCore.Rewrite.Internal.ModRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite; using Microsoft.AspNetCore.Rewrite.Internal.UrlActions; using Microsoft.AspNetCore.Rewrite.Internal.UrlMatches; -using Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite; using Xunit; namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite "; - var expected = new List(); + var expected = new List(); expected.Add(CreateTestRule(new List(), url: "^article/([0-9]+)/([_0-9a-z-]+)", name: "Rewrite to article.aspx", @@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite Match = new RegexMatch(new Regex("^OFF$"), false) }); - var expected = new List(); + var expected = new List(); expected.Add(CreateTestRule(condList, url: "^article/([0-9]+)/([_0-9a-z-]+)", name: "Rewrite to article.aspx", @@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite Match = new RegexMatch(new Regex("^OFF$"), false) }); - var expected = new List(); + var expected = new List(); expected.Add(CreateTestRule(condList, url: "^article/([0-9]+)/([_0-9a-z-]+)", name: "Rewrite to article.aspx", @@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite } // Creates a rule with appropriate default values of the url rewrite rule. - private UrlRewriteRule CreateTestRule(List conditions, + private IISUrlRewriteRule CreateTestRule(List conditions, LogicalGrouping condGrouping = LogicalGrouping.MatchAll, bool condTracking = false, string name = "", @@ -146,12 +146,12 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite RedirectType redirectType = RedirectType.Permanent ) { - return new UrlRewriteRule(name, new RegexMatch(new Regex("^OFF$"), false), conditions, + return new IISUrlRewriteRule(name, new RegexMatch(new Regex("^OFF$"), false), conditions, new RewriteAction(RuleTermination.Continue, new InputParser().ParseInputString(url), queryStringAppend: false)); } // TODO make rules comparable? - private void AssertUrlRewriteRuleEquality(IList actual, IList expected) + private void AssertUrlRewriteRuleEquality(IList actual, IList expected) { Assert.Equal(actual.Count, expected.Count); for (var i = 0; i < actual.Count; i++) diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/FormatExceptionHandlingTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/FormatExceptionHandlingTests.cs similarity index 98% rename from test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/FormatExceptionHandlingTests.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/FormatExceptionHandlingTests.cs index 41adf2fbbc..3b77f78290 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/FormatExceptionHandlingTests.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/FormatExceptionHandlingTests.cs @@ -3,7 +3,7 @@ using System; using System.IO; -using Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite; using Xunit; namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/InputParserTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/InputParserTests.cs similarity index 98% rename from test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/InputParserTests.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/InputParserTests.cs index 0f4b2ba7fb..29299a9287 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/InputParserTests.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/InputParserTests.cs @@ -5,7 +5,7 @@ using System; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Rewrite.Internal; -using Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite; using Xunit; namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/MiddleWareTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/MiddleWareTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/MiddleWareTests.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/MiddleWareTests.cs diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/ServerVariableTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/ServerVariableTests.cs similarity index 97% rename from test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/ServerVariableTests.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/ServerVariableTests.cs index 206544b447..3235ab7d1e 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/ServerVariableTests.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/ServerVariableTests.cs @@ -4,7 +4,7 @@ using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Rewrite.Internal; -using Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite; using Microsoft.Net.Http.Headers; using Xunit; diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/UrlRewriteApplicationTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/UrlRewriteApplicationTests.cs similarity index 96% rename from test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/UrlRewriteApplicationTests.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/UrlRewriteApplicationTests.cs index 8892155eff..bbb04f1f7e 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/UrlRewrite/UrlRewriteApplicationTests.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/IISUrlRewrite/UrlRewriteApplicationTests.cs @@ -4,7 +4,7 @@ using System.IO; using System.Linq; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Rewrite.Internal.UrlRewrite; +using Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite; using Xunit; namespace Microsoft.AspNetCore.Rewrite.Tests.UrlRewrite diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/CodeRules/MiddlewareTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/MiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Rewrite.Tests/CodeRules/MiddlewareTests.cs rename to test/Microsoft.AspNetCore.Rewrite.Tests/MiddlewareTests.cs