Fix server variable exception messages

This commit is contained in:
Mikael Mengistu 2016-11-03 16:45:33 -07:00 committed by GitHub
parent 222addf264
commit 623333a919
4 changed files with 67 additions and 48 deletions

View File

@ -38,51 +38,51 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite
case "HTTP_FORWARDED":
return new HeaderSegment("Forwarded");
case "AUTH_TYPE":
throw new NotSupportedException("Rules using the AUTH_TYPE server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "CONN_REMOTE_ADDR":
return new RemoteAddressSegment();
case "CONTEXT_PREFIX":
throw new NotSupportedException("Rules using the CONTEXT_PREFIX server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "CONTEXT_DOCUMENT_ROOT":
throw new NotSupportedException("Rules using the CONTEXT_DOCUMENT_ROOT server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "IPV6":
return new IsIPV6Segment();
case "PATH_INFO":
throw new NotImplementedException("Rules using the PATH_INFO server variable are not implemented");
throw new NotImplementedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "QUERY_STRING":
return new QueryStringSegment();
case "REMOTE_ADDR":
return new RemoteAddressSegment();
case "REMOTE_HOST":
throw new NotSupportedException("Rules using the REMOTE_HOST server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "REMOTE_IDENT":
throw new NotSupportedException("Rules using the REMOTE_IDENT server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "REMOTE_PORT":
return new RemotePortSegment();
case "REMOTE_USER":
throw new NotSupportedException("Rules using the REMOTE_USER server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "REQUEST_METHOD":
return new RequestMethodSegment();
case "SCRIPT_FILENAME":
return new RequestFileNameSegment();
case "DOCUMENT_ROOT":
throw new NotSupportedException("Rules using the DOCUMENT_ROOT server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "SCRIPT_GROUP":
throw new NotSupportedException("Rules using the SCRIPT_GROUP server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "SCRIPT_USER":
throw new NotSupportedException("Rules using the SCRIPT_USER server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "SERVER_ADDR":
return new LocalAddressSegment();
case "SERVER_ADMIN":
throw new NotSupportedException("Rules using the SERVER_ADMIN server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "SERVER_NAME":
throw new NotSupportedException("Rules using the SERVER_NAME server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "SERVER_PORT":
return new LocalPortSegment();
case "SERVER_PROTOCOL":
return new ServerProtocolSegment();
case "SERVER_SOFTWARE":
throw new NotSupportedException("Rules using the SERVER_SOFTWARE server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "TIME_YEAR":
return new DateTimeSegment(serverVariable);
case "TIME_MON":
@ -100,13 +100,13 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite
case "TIME":
return new DateTimeSegment(serverVariable);
case "API_VERSION":
throw new NotSupportedException("Rules using the API_VERSION server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "HTTPS":
return new IsHttpsModSegment();
case "HTTP2":
throw new NotSupportedException("Rules using the HTTP2 server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "IS_SUBREQ":
throw new NotSupportedException("Rules using the IS_SUBREQ server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "REQUEST_FILENAME":
return new RequestFileNameSegment();
case "REQUEST_SCHEME":
@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite
case "REQUEST_URI":
return new UrlSegment();
case "THE_REQUEST":
throw new NotSupportedException("Rules using the THE_REQUEST server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
default:
throw new FormatException(Resources.FormatError_InputParserUnrecognizedParameter(serverVariable, context.Index));
}

View File

@ -15,9 +15,9 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite
{
// TODO Add all server variables here.
case "ALL_RAW":
throw new NotSupportedException("Rules using the ALL_RAW server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "APP_POOL_ID":
throw new NotSupportedException("Rules using the APP_POOL_ID server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "CONTENT_LENGTH":
return new HeaderSegment(HeaderNames.ContentLength);
case "CONTENT_TYPE":
@ -41,13 +41,13 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite
case "LOCAL_ADDR":
return new LocalAddressSegment();
case "HTTP_PROXY_CONNECTION":
throw new NotSupportedException("Rules using the HTTP_PROXY_CONNECTION server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "QUERY_STRING":
return new QueryStringSegment();
case "REMOTE_ADDR":
return new RemoteAddressSegment();
case "REMOTE_HOST":
throw new NotSupportedException("Rules using the REMOTE_HOST server variable are not supported");
throw new NotSupportedException(Resources.FormatError_UnsupportedServerVariable(serverVariable));
case "REMOTE_PORT":
return new RemotePortSegment();
case "REQUEST_FILENAME":

View File

@ -202,6 +202,22 @@ namespace Microsoft.AspNetCore.Rewrite
return string.Format(CultureInfo.CurrentCulture, GetString("Error_UrlRewriteParseError"), p0, p1, p2);
}
/// <summary>
/// Rules using the '{0}' server variable are not supported
/// </summary>
internal static string Error_UnsupportedServerVariable
{
get { return GetString("Error_UnsupportedServerVariable"); }
}
/// <summary>
/// Rules using the '{0}' server variable are not supported
/// </summary>
internal static string FormatError_UnsupportedServerVariable(object p0)
{
return string.Format(CultureInfo.CurrentCulture, GetString("Error_UnsupportedServerVariable"), p0);
}
private static string GetString(string name, params string[] formatterNames)
{
var value = _resourceManager.GetString(name);

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
@ -153,4 +153,7 @@
<data name="Error_UrlRewriteParseError" xml:space="preserve">
<value>Could not parse the UrlRewrite file. Message: '{0}'. Line number '{1}': '{2}'.</value>
</data>
<data name="Error_UnsupportedServerVariable" xml:space="preserve">
<value>Rules using the '{0}' server variable are not supported</value>
</data>
</root>