Move user-facing strings into resource files

This commit is contained in:
Nate McMaster 2017-04-26 17:22:55 -07:00 committed by GitHub
parent ead08706ae
commit c2f15fcac3
31 changed files with 1592 additions and 191 deletions

View File

@ -36,64 +36,64 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
switch (reason)
{
case RequestRejectionReason.InvalidRequestHeadersNoCRLF:
ex = new BadHttpRequestException("Invalid request headers: missing final CRLF in header fields.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_InvalidRequestHeadersNoCRLF, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.InvalidRequestLine:
ex = new BadHttpRequestException("Invalid request line.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_InvalidRequestLine, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.MalformedRequestInvalidHeaders:
ex = new BadHttpRequestException("Malformed request: invalid headers.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_MalformedRequestInvalidHeaders, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.MultipleContentLengths:
ex = new BadHttpRequestException("Multiple Content-Length headers.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_MultipleContentLengths, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.UnexpectedEndOfRequestContent:
ex = new BadHttpRequestException("Unexpected end of request content.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_UnexpectedEndOfRequestContent, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.BadChunkSuffix:
ex = new BadHttpRequestException("Bad chunk suffix.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_BadChunkSuffix, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.BadChunkSizeData:
ex = new BadHttpRequestException("Bad chunk size data.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_BadChunkSizeData, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.ChunkedRequestIncomplete:
ex = new BadHttpRequestException("Chunked request incomplete.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_ChunkedRequestIncomplete, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.InvalidCharactersInHeaderName:
ex = new BadHttpRequestException("Invalid characters in header name.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_InvalidCharactersInHeaderName, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.RequestLineTooLong:
ex = new BadHttpRequestException("Request line too long.", StatusCodes.Status414UriTooLong);
ex = new BadHttpRequestException(CoreStrings.BadRequest_RequestLineTooLong, StatusCodes.Status414UriTooLong);
break;
case RequestRejectionReason.HeadersExceedMaxTotalSize:
ex = new BadHttpRequestException("Request headers too long.", StatusCodes.Status431RequestHeaderFieldsTooLarge);
ex = new BadHttpRequestException(CoreStrings.BadRequest_HeadersExceedMaxTotalSize, StatusCodes.Status431RequestHeaderFieldsTooLarge);
break;
case RequestRejectionReason.TooManyHeaders:
ex = new BadHttpRequestException("Request contains too many headers.", StatusCodes.Status431RequestHeaderFieldsTooLarge);
ex = new BadHttpRequestException(CoreStrings.BadRequest_TooManyHeaders, StatusCodes.Status431RequestHeaderFieldsTooLarge);
break;
case RequestRejectionReason.RequestTimeout:
ex = new BadHttpRequestException("Request timed out.", StatusCodes.Status408RequestTimeout);
ex = new BadHttpRequestException(CoreStrings.BadRequest_RequestTimeout, StatusCodes.Status408RequestTimeout);
break;
case RequestRejectionReason.OptionsMethodRequired:
ex = new BadHttpRequestException("Method not allowed.", StatusCodes.Status405MethodNotAllowed, HttpMethod.Options);
ex = new BadHttpRequestException(CoreStrings.BadRequest_MethodNotAllowed, StatusCodes.Status405MethodNotAllowed, HttpMethod.Options);
break;
case RequestRejectionReason.ConnectMethodRequired:
ex = new BadHttpRequestException("Method not allowed.", StatusCodes.Status405MethodNotAllowed, HttpMethod.Connect);
ex = new BadHttpRequestException(CoreStrings.BadRequest_MethodNotAllowed, StatusCodes.Status405MethodNotAllowed, HttpMethod.Connect);
break;
case RequestRejectionReason.MissingHostHeader:
ex = new BadHttpRequestException("Request is missing Host header.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_MissingHostHeader, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.MultipleHostHeaders:
ex = new BadHttpRequestException("Multiple Host headers.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_MultipleHostHeaders, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.InvalidHostHeader:
ex = new BadHttpRequestException("Invalid Host header.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_InvalidHostHeader, StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.UpgradeRequestCannotHavePayload:
ex = new BadHttpRequestException("Requests with 'Connection: Upgrade' cannot have content in the request body.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest_UpgradeRequestCannotHavePayload, StatusCodes.Status400BadRequest);
break;
default:
ex = new BadHttpRequestException("Bad request.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest, StatusCodes.Status400BadRequest);
break;
}
return ex;
@ -105,34 +105,34 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
switch (reason)
{
case RequestRejectionReason.InvalidRequestLine:
ex = new BadHttpRequestException($"Invalid request line: '{detail}'", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.FormatBadRequest_InvalidRequestLine_Detail(detail), StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.InvalidRequestTarget:
ex = new BadHttpRequestException($"Invalid request target: '{detail}'", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.FormatBadRequest_InvalidRequestTarget_Detail(detail), StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.InvalidRequestHeader:
ex = new BadHttpRequestException($"Invalid request header: '{detail}'", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(detail), StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.InvalidContentLength:
ex = new BadHttpRequestException($"Invalid content length: {detail}", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.FormatBadRequest_InvalidContentLength_Detail(detail), StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.UnrecognizedHTTPVersion:
ex = new BadHttpRequestException($"Unrecognized HTTP version: '{detail}'", StatusCodes.Status505HttpVersionNotsupported);
ex = new BadHttpRequestException(CoreStrings.FormatBadRequest_UnrecognizedHTTPVersion(detail), StatusCodes.Status505HttpVersionNotsupported);
break;
case RequestRejectionReason.FinalTransferCodingNotChunked:
ex = new BadHttpRequestException($"Final transfer coding is not \"chunked\": \"{detail}\"", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.FormatBadRequest_FinalTransferCodingNotChunked(detail), StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.LengthRequired:
ex = new BadHttpRequestException($"{detail} request contains no Content-Length or Transfer-Encoding header", StatusCodes.Status411LengthRequired);
ex = new BadHttpRequestException(CoreStrings.FormatBadRequest_LengthRequired(detail), StatusCodes.Status411LengthRequired);
break;
case RequestRejectionReason.LengthRequiredHttp10:
ex = new BadHttpRequestException($"{detail} request contains no Content-Length header", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.FormatBadRequest_LengthRequiredHttp10(detail), StatusCodes.Status400BadRequest);
break;
case RequestRejectionReason.InvalidHostHeader:
ex = new BadHttpRequestException($"Invalid Host header: '{detail}'", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.FormatBadRequest_InvalidHostHeader_Detail(detail), StatusCodes.Status400BadRequest);
break;
default:
ex = new BadHttpRequestException("Bad request.", StatusCodes.Status400BadRequest);
ex = new BadHttpRequestException(CoreStrings.BadRequest, StatusCodes.Status400BadRequest);
break;
}
return ex;

View File

@ -117,10 +117,193 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="BadRequest" xml:space="preserve">
<value>Bad request.</value>
</data>
<data name="BadRequest_BadChunkSizeData" xml:space="preserve">
<value>Bad chunk size data.</value>
</data>
<data name="BadRequest_BadChunkSuffix" xml:space="preserve">
<value>Bad chunk suffix.</value>
</data>
<data name="BadRequest_ChunkedRequestIncomplete" xml:space="preserve">
<value>Chunked request incomplete.</value>
</data>
<data name="BadRequest_FinalTransferCodingNotChunked" xml:space="preserve">
<value>The message body length cannot be determined because the final transfer coding was set to '{detail}' instead of 'chunked'.</value>
</data>
<data name="BadRequest_HeadersExceedMaxTotalSize" xml:space="preserve">
<value>Request headers too long.</value>
</data>
<data name="BadRequest_InvalidCharactersInHeaderName" xml:space="preserve">
<value>Invalid characters in header name.</value>
</data>
<data name="BadRequest_InvalidContentLength_Detail" xml:space="preserve">
<value>Invalid content length: {detail}</value>
</data>
<data name="BadRequest_InvalidHostHeader" xml:space="preserve">
<value>Invalid Host header.</value>
</data>
<data name="BadRequest_InvalidHostHeader_Detail" xml:space="preserve">
<value>Invalid Host header: '{detail}'</value>
</data>
<data name="BadRequest_InvalidRequestHeadersNoCRLF" xml:space="preserve">
<value>Invalid request headers: missing final CRLF in header fields.</value>
</data>
<data name="BadRequest_InvalidRequestHeader_Detail" xml:space="preserve">
<value>Invalid request header: '{detail}'</value>
</data>
<data name="BadRequest_InvalidRequestLine" xml:space="preserve">
<value>Invalid request line.</value>
</data>
<data name="BadRequest_InvalidRequestLine_Detail" xml:space="preserve">
<value>Invalid request line: '{detail}'</value>
</data>
<data name="BadRequest_InvalidRequestTarget_Detail" xml:space="preserve">
<value>Invalid request target: '{detail}'</value>
</data>
<data name="BadRequest_LengthRequired" xml:space="preserve">
<value>{detail} request contains no Content-Length or Transfer-Encoding header.</value>
</data>
<data name="BadRequest_LengthRequiredHttp10" xml:space="preserve">
<value>{detail} request contains no Content-Length header.</value>
</data>
<data name="BadRequest_MalformedRequestInvalidHeaders" xml:space="preserve">
<value>Malformed request: invalid headers.</value>
</data>
<data name="BadRequest_MethodNotAllowed" xml:space="preserve">
<value>Method not allowed.</value>
</data>
<data name="BadRequest_MissingHostHeader" xml:space="preserve">
<value>Request is missing Host header.</value>
</data>
<data name="BadRequest_MultipleContentLengths" xml:space="preserve">
<value>Multiple Content-Length headers.</value>
</data>
<data name="BadRequest_MultipleHostHeaders" xml:space="preserve">
<value>Multiple Host headers.</value>
</data>
<data name="BadRequest_RequestLineTooLong" xml:space="preserve">
<value>Request line too long.</value>
</data>
<data name="BadRequest_RequestTimeout" xml:space="preserve">
<value>Request timed out.</value>
</data>
<data name="BadRequest_TooManyHeaders" xml:space="preserve">
<value>Request contains too many headers.</value>
</data>
<data name="BadRequest_UnexpectedEndOfRequestContent" xml:space="preserve">
<value>Unexpected end of request content.</value>
</data>
<data name="BadRequest_UnrecognizedHTTPVersion" xml:space="preserve">
<value>Unrecognized HTTP version: '{detail}'</value>
</data>
<data name="BadRequest_UpgradeRequestCannotHavePayload" xml:space="preserve">
<value>Requests with 'Connection: Upgrade' cannot have content in the request body.</value>
</data>
<data name="FallbackToIPv4Any" xml:space="preserve">
<value>Failed to bind to http://[::]:{port} (IPv6Any). Attempting to bind to http://0.0.0.0:{port} instead.</value>
</data>
<data name="ResponseStreamWasUpgraded" xml:space="preserve">
<value>Cannot write to response body after connection has been upgraded.</value>
</data>
<data name="BigEndianNotSupported" xml:space="preserve">
<value>Kestrel does not support big-endian architectures.</value>
</data>
<data name="MaxRequestBufferSmallerThanRequestHeaderBuffer" xml:space="preserve">
<value>Maximum request buffer size ({requestBufferSize}) must be greater than or equal to maximum request header size ({requestHeaderSize}).</value>
</data>
<data name="MaxRequestBufferSmallerThanRequestLineBuffer" xml:space="preserve">
<value>Maximum request buffer size ({requestBufferSize}) must be greater than or equal to maximum request line size ({requestLineSize}).</value>
</data>
<data name="ServerAlreadyStarted" xml:space="preserve">
<value>Server has already started.</value>
</data>
<data name="UnknownTransportMode" xml:space="preserve">
<value>Unknown transport mode: '{mode}'.</value>
</data>
<data name="InvalidAsciiOrControlChar" xml:space="preserve">
<value>Invalid non-ASCII or control character in header: {character}</value>
</data>
<data name="InvalidContentLength_InvalidNumber" xml:space="preserve">
<value>Invalid Content-Length: "{value}". Value must be a positive integral number.</value>
</data>
<data name="NonNegativeNullableIntRequired" xml:space="preserve">
<value>Value must be null or a non-negative integer.</value>
</data>
<data name="PositiveIntRequired" xml:space="preserve">
<value>Value must be a positive integer.</value>
</data>
<data name="PositiveNullableIntRequired" xml:space="preserve">
<value>Value must be null or a positive integer.</value>
</data>
<data name="UnixSocketPathMustBeAbsolute" xml:space="preserve">
<value>Unix socket path must be absolute.</value>
</data>
<data name="AddressBindingFailed" xml:space="preserve">
<value>Failed to bind to address {address}.</value>
</data>
<data name="BindingToDefaultAddress" xml:space="preserve">
<value>No listening endpoints were configured. Binding to {address} by default.</value>
</data>
<data name="ConfigureHttpsFromMethodCall" xml:space="preserve">
<value>HTTPS endpoints can only be configured using {methodName}.</value>
</data>
<data name="ConfigurePathBaseFromMethodCall" xml:space="preserve">
<value>A path base can only be configured using {methodName}.</value>
</data>
<data name="DynamicPortOnLocalhostNotSupported" xml:space="preserve">
<value>Dynamic port binding is not supported when binding to localhost. You must either bind to 127.0.0.1:0 or [::1]:0, or both.</value>
</data>
<data name="EndpointAlreadyInUse" xml:space="preserve">
<value>Failed to bind to address {endpoint}: address already in use.</value>
</data>
<data name="InvalidUrl" xml:space="preserve">
<value>Invalid URL: '{url}'.</value>
</data>
<data name="NetworkInterfaceBindingFailed" xml:space="preserve">
<value>Unable to bind to {address} on the {interfaceName} interface: '{error}'.</value>
</data>
<data name="OverridingWithKestrelOptions" xml:space="preserve">
<value>Overriding address(es) '{addresses}'. Binding to endpoints defined in {methodName} instead.</value>
</data>
<data name="OverridingWithPreferHostingUrls" xml:space="preserve">
<value>Overriding endpoints defined in UseKestrel() because {settingName} is set to true. Binding to address(es) '{addresses}' instead.</value>
</data>
<data name="UnsupportedAddressScheme" xml:space="preserve">
<value>Unrecognized scheme in server address '{address}'. Only 'http://' is supported.</value>
</data>
<data name="HeadersAreReadOnly" xml:space="preserve">
<value>Headers are read-only, response has already started.</value>
</data>
<data name="KeyAlreadyExists" xml:space="preserve">
<value>An item with the same key has already been added.</value>
</data>
<data name="HeaderNotAllowedOnResponse" xml:space="preserve">
<value>Setting the header {name} is not allowed on responses with status code {statusCode}.</value>
</data>
<data name="ParameterReadOnlyAfterResponseStarted" xml:space="preserve">
<value>{name} cannot be set because the response has already started.</value>
</data>
<data name="RequestProcessingAborted" xml:space="preserve">
<value>Request processing didn't complete within the shutdown timeout.</value>
</data>
<data name="TooFewBytesWritten" xml:space="preserve">
<value>Response Content-Length mismatch: too few bytes written ({written} of {expected}).</value>
</data>
<data name="TooManyBytesWritten" xml:space="preserve">
<value>Response Content-Length mismatch: too many bytes written ({written} of {expected}).</value>
</data>
<data name="UnhandledApplicationException" xml:space="preserve">
<value>The response has been aborted due to an unhandled application exception.</value>
</data>
<data name="WritingToResponseBodyNotSupported" xml:space="preserve">
<value>Writing to the response body is invalid for responses with status code {statusCode}.</value>
</data>
<data name="ConnectionShutdownError" xml:space="preserve">
<value>Connection shutdown abnormally.</value>
</data>
<data name="RequestProcessingEndError" xml:space="preserve">
<value>Connection processing ended abnormally.</value>
</data>
</root>

View File

@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
}
catch (AddressInUseException ex)
{
throw new IOException($"Failed to bind to address {endpoint}: address already in use.", ex);
throw new IOException(CoreStrings.FormatEndpointAlreadyInUse(endpoint), ex);
}
context.ListenOptions.Add(endpoint);
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
if (address.Port == 0)
{
throw new InvalidOperationException("Dynamic port binding is not supported when binding to localhost. You must either bind to 127.0.0.1:0 or [::1]:0, or both.");
throw new InvalidOperationException(CoreStrings.DynamicPortOnLocalhostNotSupported);
}
var exceptions = new List<Exception>();
@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
}
catch (Exception ex) when (!(ex is IOException))
{
context.Logger.LogWarning(0, $"Unable to bind to {address} on the IPv4 loopback interface: ({ex.Message})");
context.Logger.LogWarning(0, CoreStrings.NetworkInterfaceBindingFailed, address, "IPv4 loopback", ex.Message);
exceptions.Add(ex);
}
@ -145,13 +145,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
}
catch (Exception ex) when (!(ex is IOException))
{
context.Logger.LogWarning(0, $"Unable to bind to {address} on the IPv6 loopback interface: ({ex.Message})");
context.Logger.LogWarning(0, CoreStrings.NetworkInterfaceBindingFailed, address, "IPv6 loopback", ex.Message);
exceptions.Add(ex);
}
if (exceptions.Count == 2)
{
throw new IOException($"Failed to bind to address {address}.", new AggregateException(exceptions));
throw new IOException(CoreStrings.FormatAddressBindingFailed(address), new AggregateException(exceptions));
}
// If StartLocalhost doesn't throw, there is at least one listener.
@ -165,16 +165,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
if (parsedAddress.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase))
{
throw new InvalidOperationException($"HTTPS endpoints can only be configured using {nameof(KestrelServerOptions)}.{nameof(KestrelServerOptions.Listen)}().");
throw new InvalidOperationException(CoreStrings.FormatConfigureHttpsFromMethodCall($"{nameof(KestrelServerOptions)}.{nameof(KestrelServerOptions.Listen)}()"));
}
else if (!parsedAddress.Scheme.Equals("http", StringComparison.OrdinalIgnoreCase))
{
throw new InvalidOperationException($"Unrecognized scheme in server address '{address}'. Only 'http://' is supported.");
throw new InvalidOperationException(CoreStrings.FormatUnsupportedAddressScheme(address));
}
if (!string.IsNullOrEmpty(parsedAddress.PathBase))
{
throw new InvalidOperationException($"A path base can only be configured using {nameof(IApplicationBuilder)}.UsePathBase().");
throw new InvalidOperationException(CoreStrings.FormatConfigurePathBaseFromMethodCall($"{nameof(IApplicationBuilder)}.UsePathBase()"));
}
if (parsedAddress.IsUnixPipe)
@ -227,7 +227,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public async Task BindAsync(AddressBindContext context)
{
context.Logger.LogDebug($"No listening endpoints were configured. Binding to {Constants.DefaultServerAddress} by default.");
context.Logger.LogDebug(CoreStrings.BindingToDefaultAddress, Constants.DefaultServerAddress);
await BindLocalhostAsync(ServerAddress.FromUrl(Constants.DefaultServerAddress), context).ConfigureAwait(false);
}
@ -243,7 +243,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
public override Task BindAsync(AddressBindContext context)
{
var joined = string.Join(", ", _addresses);
context.Logger.LogInformation($"Overriding endpoints defined in UseKestrel() since {nameof(IServerAddressesFeature.PreferHostingUrls)} is set to true. Binding to address(es) '{joined}' instead.");
context.Logger.LogInformation(CoreStrings.OverridingWithPreferHostingUrls, nameof(IServerAddressesFeature.PreferHostingUrls), joined);
return base.BindAsync(context);
}
@ -262,7 +262,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
public override Task BindAsync(AddressBindContext context)
{
var joined = string.Join(", ", _originalAddresses);
context.Logger.LogWarning($"Overriding address(es) {joined}. Binding to endpoints defined in UseKestrel() instead.");
context.Logger.LogWarning(CoreStrings.OverridingWithKestrelOptions, joined, "UseKestrel()");
return base.BindAsync(context);
}

View File

@ -661,7 +661,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
_keepAlive = false;
throw new InvalidOperationException(
$"Response Content-Length mismatch: too many bytes written ({_responseBytesWritten + count} of {responseHeaders.ContentLength.Value}).");
CoreStrings.FormatTooManyBytesWritten(_responseBytesWritten + count, responseHeaders.ContentLength.Value));
}
_responseBytesWritten += count;
@ -702,7 +702,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
}
ReportApplicationError(new InvalidOperationException(
$"Response Content-Length mismatch: too few bytes written ({_responseBytesWritten} of {responseHeaders.ContentLength.Value})."));
CoreStrings.FormatTooFewBytesWritten(_responseBytesWritten, responseHeaders.ContentLength.Value)));
}
}
@ -1081,12 +1081,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
private void ThrowResponseAlreadyStartedException(string value)
{
throw new InvalidOperationException($"{value} cannot be set, response has already started.");
throw new InvalidOperationException(CoreStrings.FormatParameterReadOnlyAfterResponseStarted(value));
}
private void RejectNonBodyTransferEncodingResponse(bool appCompleted)
{
var ex = new InvalidOperationException($"Transfer-Encoding set on a {StatusCode} non-body request.");
var ex = new InvalidOperationException(CoreStrings.FormatHeaderNotAllowedOnResponse("Transfer-Encoding", StatusCode));
if (!appCompleted)
{
// Back out of header creation surface exeception in user code
@ -1143,15 +1143,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
if (Method != "HEAD")
{
// Throw Exception for 204, 205, 304 responses.
throw new InvalidOperationException($"Write to non-body {StatusCode} response.");
throw new InvalidOperationException(CoreStrings.FormatWritingToResponseBodyNotSupported(StatusCode));
}
}
private void ThrowResponseAbortedException()
{
throw new ObjectDisposedException(
"The response has been aborted due to an unhandled application exception.",
_applicationException);
throw new ObjectDisposedException(CoreStrings.UnhandledApplicationException, _applicationException);
}
public void RejectRequest(RequestRejectionReason reason)

View File

@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
protected void ThrowHeadersReadOnlyException()
{
throw new InvalidOperationException("Headers are read-only, response has already started.");
throw new InvalidOperationException(CoreStrings.HeadersAreReadOnly);
}
protected void ThrowArgumentException()
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
protected void ThrowDuplicateKeyException()
{
throw new ArgumentException("An item with the same key has already been added.");
throw new ArgumentException(CoreStrings.KeyAlreadyExists);
}
int ICollection<KeyValuePair<string, StringValues>>.Count => GetCountFast();
@ -426,12 +426,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
private static void ThrowInvalidContentLengthException(long value)
{
throw new ArgumentOutOfRangeException($"Invalid Content-Length: \"{value}\". Value must be a positive integral number.");
throw new ArgumentOutOfRangeException(CoreStrings.FormatInvalidContentLength_InvalidNumber(value));
}
private static void ThrowInvalidHeaderCharacter(char ch)
{
throw new InvalidOperationException(string.Format("Invalid non-ASCII or control character in header: 0x{0:X4}", (ushort)ch));
throw new InvalidOperationException(CoreStrings.FormatInvalidAsciiOrControlChar(string.Format("0x{0:X4}", (ushort)ch)));
}
}
}

View File

@ -227,7 +227,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
}
catch (Exception ex)
{
Log.LogWarning(0, ex, "Connection processing ended abnormally");
Log.LogWarning(0, ex, CoreStrings.RequestProcessingEndError);
}
finally
{
@ -243,7 +243,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
}
catch (Exception ex)
{
Log.LogWarning(0, ex, "Connection shutdown abnormally");
Log.LogWarning(0, ex, CoreStrings.ConnectionShutdownError);
}
}
}

View File

@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
}
if (bufferSize <= 0)
{
throw new ArgumentException($"{nameof(bufferSize)} must be positive.", nameof(bufferSize));
throw new ArgumentException(CoreStrings.PositiveIntRequired, nameof(bufferSize));
}
var task = ValidateState(cancellationToken);

View File

@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
private static void ThrowInvalidContentLengthException(string value)
{
throw new InvalidOperationException($"Invalid Content-Length: \"{value}\". Value must be a positive integral number.");
throw new InvalidOperationException(CoreStrings.FormatInvalidContentLength_InvalidNumber(value));
}
public partial struct Enumerator : IEnumerator<KeyValuePair<string, StringValues>>

View File

@ -1,9 +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.
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -27,7 +25,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
public static async Task<bool> AbortAllConnectionsAsync(this FrameConnectionManager connectionManager)
{
var abortTasks = new List<Task>();
var canceledException = new TaskCanceledException("Request processing didn't complete within the shutdown timeout.");
var canceledException = new TaskCanceledException(CoreStrings.RequestProcessingAborted);
connectionManager.Walk(connection =>
{

View File

@ -85,7 +85,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
threadPool = new InlineLoggingThreadPool(trace);
break;
default:
throw new NotSupportedException($"Unknown transport mode {serverOptions.ApplicationSchedulingMode}");
throw new NotSupportedException(CoreStrings.FormatUnknownTransportMode(serverOptions.ApplicationSchedulingMode));
}
return new ServiceContext
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
if (!BitConverter.IsLittleEndian)
{
throw new PlatformNotSupportedException("Kestrel does not support big-endian architectures.");
throw new PlatformNotSupportedException(CoreStrings.BigEndianNotSupported);
}
ValidateOptions();
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
if (_hasStarted)
{
// The server has already started and/or has not been cleaned up yet
throw new InvalidOperationException("Server has already started.");
throw new InvalidOperationException(CoreStrings.ServerAlreadyStarted);
}
_hasStarted = true;
_heartbeat.Start();
@ -196,14 +196,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
Options.Limits.MaxRequestBufferSize < Options.Limits.MaxRequestLineSize)
{
throw new InvalidOperationException(
$"Maximum request buffer size ({Options.Limits.MaxRequestBufferSize.Value}) must be greater than or equal to maximum request line size ({Options.Limits.MaxRequestLineSize}).");
CoreStrings.FormatMaxRequestBufferSmallerThanRequestLineBuffer(Options.Limits.MaxRequestBufferSize.Value, Options.Limits.MaxRequestLineSize));
}
if (Options.Limits.MaxRequestBufferSize.HasValue &&
Options.Limits.MaxRequestBufferSize < Options.Limits.MaxRequestHeadersTotalSize)
{
throw new InvalidOperationException(
$"Maximum request buffer size ({Options.Limits.MaxRequestBufferSize.Value}) must be greater than or equal to maximum request headers size ({Options.Limits.MaxRequestHeadersTotalSize}).");
CoreStrings.FormatMaxRequestBufferSmallerThanRequestHeaderBuffer(Options.Limits.MaxRequestBufferSize.Value, Options.Limits.MaxRequestHeadersTotalSize));
}
}
}

View File

@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
if (value.HasValue && value.Value < 0)
{
throw new ArgumentOutOfRangeException(nameof(value), "Value must be null or a non-negative integer.");
throw new ArgumentOutOfRangeException(nameof(value), CoreStrings.NonNegativeNullableIntRequired);
}
_maxResponseBufferSize = value;
}
@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
if (value.HasValue && value.Value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value), "Value must be null or a positive integer.");
throw new ArgumentOutOfRangeException(nameof(value), CoreStrings.PositiveNullableIntRequired);
}
_maxRequestBufferSize = value;
}
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value), "Value must be a positive integer.");
throw new ArgumentOutOfRangeException(nameof(value), CoreStrings.PositiveIntRequired);
}
_maxRequestLineSize = value;
}
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value), "Value must a positive integer.");
throw new ArgumentOutOfRangeException(nameof(value), CoreStrings.PositiveIntRequired);
}
_maxRequestHeadersTotalSize = value;
}
@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException(nameof(value), "Value must a positive integer.");
throw new ArgumentOutOfRangeException(nameof(value), CoreStrings.PositiveIntRequired);
}
_maxRequestHeaderCount = value;
}

View File

@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
}
if (socketPath.Length == 0 || socketPath[0] != '/')
{
throw new ArgumentException("Unix socket path must be absolute.", nameof(socketPath));
throw new ArgumentException(CoreStrings.UnixSocketPathMustBeAbsolute, nameof(socketPath));
}
if (configure == null)
{

View File

@ -10,6 +10,398 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
private static readonly ResourceManager _resourceManager
= new ResourceManager("Microsoft.AspNetCore.Server.Kestrel.Core.CoreStrings", typeof(CoreStrings).GetTypeInfo().Assembly);
/// <summary>
/// Bad request.
/// </summary>
internal static string BadRequest
{
get => GetString("BadRequest");
}
/// <summary>
/// Bad request.
/// </summary>
internal static string FormatBadRequest()
=> GetString("BadRequest");
/// <summary>
/// Bad chunk size data.
/// </summary>
internal static string BadRequest_BadChunkSizeData
{
get => GetString("BadRequest_BadChunkSizeData");
}
/// <summary>
/// Bad chunk size data.
/// </summary>
internal static string FormatBadRequest_BadChunkSizeData()
=> GetString("BadRequest_BadChunkSizeData");
/// <summary>
/// Bad chunk suffix.
/// </summary>
internal static string BadRequest_BadChunkSuffix
{
get => GetString("BadRequest_BadChunkSuffix");
}
/// <summary>
/// Bad chunk suffix.
/// </summary>
internal static string FormatBadRequest_BadChunkSuffix()
=> GetString("BadRequest_BadChunkSuffix");
/// <summary>
/// Chunked request incomplete.
/// </summary>
internal static string BadRequest_ChunkedRequestIncomplete
{
get => GetString("BadRequest_ChunkedRequestIncomplete");
}
/// <summary>
/// Chunked request incomplete.
/// </summary>
internal static string FormatBadRequest_ChunkedRequestIncomplete()
=> GetString("BadRequest_ChunkedRequestIncomplete");
/// <summary>
/// The message body length cannot be determined because the final transfer coding was set to '{detail}' instead of 'chunked'.
/// </summary>
internal static string BadRequest_FinalTransferCodingNotChunked
{
get => GetString("BadRequest_FinalTransferCodingNotChunked");
}
/// <summary>
/// The message body length cannot be determined because the final transfer coding was set to '{detail}' instead of 'chunked'.
/// </summary>
internal static string FormatBadRequest_FinalTransferCodingNotChunked(object detail)
=> string.Format(CultureInfo.CurrentCulture, GetString("BadRequest_FinalTransferCodingNotChunked", "detail"), detail);
/// <summary>
/// Request headers too long.
/// </summary>
internal static string BadRequest_HeadersExceedMaxTotalSize
{
get => GetString("BadRequest_HeadersExceedMaxTotalSize");
}
/// <summary>
/// Request headers too long.
/// </summary>
internal static string FormatBadRequest_HeadersExceedMaxTotalSize()
=> GetString("BadRequest_HeadersExceedMaxTotalSize");
/// <summary>
/// Invalid characters in header name.
/// </summary>
internal static string BadRequest_InvalidCharactersInHeaderName
{
get => GetString("BadRequest_InvalidCharactersInHeaderName");
}
/// <summary>
/// Invalid characters in header name.
/// </summary>
internal static string FormatBadRequest_InvalidCharactersInHeaderName()
=> GetString("BadRequest_InvalidCharactersInHeaderName");
/// <summary>
/// Invalid content length: {detail}
/// </summary>
internal static string BadRequest_InvalidContentLength_Detail
{
get => GetString("BadRequest_InvalidContentLength_Detail");
}
/// <summary>
/// Invalid content length: {detail}
/// </summary>
internal static string FormatBadRequest_InvalidContentLength_Detail(object detail)
=> string.Format(CultureInfo.CurrentCulture, GetString("BadRequest_InvalidContentLength_Detail", "detail"), detail);
/// <summary>
/// Invalid Host header.
/// </summary>
internal static string BadRequest_InvalidHostHeader
{
get => GetString("BadRequest_InvalidHostHeader");
}
/// <summary>
/// Invalid Host header.
/// </summary>
internal static string FormatBadRequest_InvalidHostHeader()
=> GetString("BadRequest_InvalidHostHeader");
/// <summary>
/// Invalid Host header: '{detail}'
/// </summary>
internal static string BadRequest_InvalidHostHeader_Detail
{
get => GetString("BadRequest_InvalidHostHeader_Detail");
}
/// <summary>
/// Invalid Host header: '{detail}'
/// </summary>
internal static string FormatBadRequest_InvalidHostHeader_Detail(object detail)
=> string.Format(CultureInfo.CurrentCulture, GetString("BadRequest_InvalidHostHeader_Detail", "detail"), detail);
/// <summary>
/// Invalid request headers: missing final CRLF in header fields.
/// </summary>
internal static string BadRequest_InvalidRequestHeadersNoCRLF
{
get => GetString("BadRequest_InvalidRequestHeadersNoCRLF");
}
/// <summary>
/// Invalid request headers: missing final CRLF in header fields.
/// </summary>
internal static string FormatBadRequest_InvalidRequestHeadersNoCRLF()
=> GetString("BadRequest_InvalidRequestHeadersNoCRLF");
/// <summary>
/// Invalid request header: '{detail}'
/// </summary>
internal static string BadRequest_InvalidRequestHeader_Detail
{
get => GetString("BadRequest_InvalidRequestHeader_Detail");
}
/// <summary>
/// Invalid request header: '{detail}'
/// </summary>
internal static string FormatBadRequest_InvalidRequestHeader_Detail(object detail)
=> string.Format(CultureInfo.CurrentCulture, GetString("BadRequest_InvalidRequestHeader_Detail", "detail"), detail);
/// <summary>
/// Invalid request line.
/// </summary>
internal static string BadRequest_InvalidRequestLine
{
get => GetString("BadRequest_InvalidRequestLine");
}
/// <summary>
/// Invalid request line.
/// </summary>
internal static string FormatBadRequest_InvalidRequestLine()
=> GetString("BadRequest_InvalidRequestLine");
/// <summary>
/// Invalid request line: '{detail}'
/// </summary>
internal static string BadRequest_InvalidRequestLine_Detail
{
get => GetString("BadRequest_InvalidRequestLine_Detail");
}
/// <summary>
/// Invalid request line: '{detail}'
/// </summary>
internal static string FormatBadRequest_InvalidRequestLine_Detail(object detail)
=> string.Format(CultureInfo.CurrentCulture, GetString("BadRequest_InvalidRequestLine_Detail", "detail"), detail);
/// <summary>
/// Invalid request target: '{detail}'
/// </summary>
internal static string BadRequest_InvalidRequestTarget_Detail
{
get => GetString("BadRequest_InvalidRequestTarget_Detail");
}
/// <summary>
/// Invalid request target: '{detail}'
/// </summary>
internal static string FormatBadRequest_InvalidRequestTarget_Detail(object detail)
=> string.Format(CultureInfo.CurrentCulture, GetString("BadRequest_InvalidRequestTarget_Detail", "detail"), detail);
/// <summary>
/// {detail} request contains no Content-Length or Transfer-Encoding header.
/// </summary>
internal static string BadRequest_LengthRequired
{
get => GetString("BadRequest_LengthRequired");
}
/// <summary>
/// {detail} request contains no Content-Length or Transfer-Encoding header.
/// </summary>
internal static string FormatBadRequest_LengthRequired(object detail)
=> string.Format(CultureInfo.CurrentCulture, GetString("BadRequest_LengthRequired", "detail"), detail);
/// <summary>
/// {detail} request contains no Content-Length header.
/// </summary>
internal static string BadRequest_LengthRequiredHttp10
{
get => GetString("BadRequest_LengthRequiredHttp10");
}
/// <summary>
/// {detail} request contains no Content-Length header.
/// </summary>
internal static string FormatBadRequest_LengthRequiredHttp10(object detail)
=> string.Format(CultureInfo.CurrentCulture, GetString("BadRequest_LengthRequiredHttp10", "detail"), detail);
/// <summary>
/// Malformed request: invalid headers.
/// </summary>
internal static string BadRequest_MalformedRequestInvalidHeaders
{
get => GetString("BadRequest_MalformedRequestInvalidHeaders");
}
/// <summary>
/// Malformed request: invalid headers.
/// </summary>
internal static string FormatBadRequest_MalformedRequestInvalidHeaders()
=> GetString("BadRequest_MalformedRequestInvalidHeaders");
/// <summary>
/// Method not allowed.
/// </summary>
internal static string BadRequest_MethodNotAllowed
{
get => GetString("BadRequest_MethodNotAllowed");
}
/// <summary>
/// Method not allowed.
/// </summary>
internal static string FormatBadRequest_MethodNotAllowed()
=> GetString("BadRequest_MethodNotAllowed");
/// <summary>
/// Request is missing Host header.
/// </summary>
internal static string BadRequest_MissingHostHeader
{
get => GetString("BadRequest_MissingHostHeader");
}
/// <summary>
/// Request is missing Host header.
/// </summary>
internal static string FormatBadRequest_MissingHostHeader()
=> GetString("BadRequest_MissingHostHeader");
/// <summary>
/// Multiple Content-Length headers.
/// </summary>
internal static string BadRequest_MultipleContentLengths
{
get => GetString("BadRequest_MultipleContentLengths");
}
/// <summary>
/// Multiple Content-Length headers.
/// </summary>
internal static string FormatBadRequest_MultipleContentLengths()
=> GetString("BadRequest_MultipleContentLengths");
/// <summary>
/// Multiple Host headers.
/// </summary>
internal static string BadRequest_MultipleHostHeaders
{
get => GetString("BadRequest_MultipleHostHeaders");
}
/// <summary>
/// Multiple Host headers.
/// </summary>
internal static string FormatBadRequest_MultipleHostHeaders()
=> GetString("BadRequest_MultipleHostHeaders");
/// <summary>
/// Request line too long.
/// </summary>
internal static string BadRequest_RequestLineTooLong
{
get => GetString("BadRequest_RequestLineTooLong");
}
/// <summary>
/// Request line too long.
/// </summary>
internal static string FormatBadRequest_RequestLineTooLong()
=> GetString("BadRequest_RequestLineTooLong");
/// <summary>
/// Request timed out.
/// </summary>
internal static string BadRequest_RequestTimeout
{
get => GetString("BadRequest_RequestTimeout");
}
/// <summary>
/// Request timed out.
/// </summary>
internal static string FormatBadRequest_RequestTimeout()
=> GetString("BadRequest_RequestTimeout");
/// <summary>
/// Request contains too many headers.
/// </summary>
internal static string BadRequest_TooManyHeaders
{
get => GetString("BadRequest_TooManyHeaders");
}
/// <summary>
/// Request contains too many headers.
/// </summary>
internal static string FormatBadRequest_TooManyHeaders()
=> GetString("BadRequest_TooManyHeaders");
/// <summary>
/// Unexpected end of request content.
/// </summary>
internal static string BadRequest_UnexpectedEndOfRequestContent
{
get => GetString("BadRequest_UnexpectedEndOfRequestContent");
}
/// <summary>
/// Unexpected end of request content.
/// </summary>
internal static string FormatBadRequest_UnexpectedEndOfRequestContent()
=> GetString("BadRequest_UnexpectedEndOfRequestContent");
/// <summary>
/// Unrecognized HTTP version: '{detail}'
/// </summary>
internal static string BadRequest_UnrecognizedHTTPVersion
{
get => GetString("BadRequest_UnrecognizedHTTPVersion");
}
/// <summary>
/// Unrecognized HTTP version: '{detail}'
/// </summary>
internal static string FormatBadRequest_UnrecognizedHTTPVersion(object detail)
=> string.Format(CultureInfo.CurrentCulture, GetString("BadRequest_UnrecognizedHTTPVersion", "detail"), detail);
/// <summary>
/// Requests with 'Connection: Upgrade' cannot have content in the request body.
/// </summary>
internal static string BadRequest_UpgradeRequestCannotHavePayload
{
get => GetString("BadRequest_UpgradeRequestCannotHavePayload");
}
/// <summary>
/// Requests with 'Connection: Upgrade' cannot have content in the request body.
/// </summary>
internal static string FormatBadRequest_UpgradeRequestCannotHavePayload()
=> GetString("BadRequest_UpgradeRequestCannotHavePayload");
/// <summary>
/// Failed to bind to http://[::]:{port} (IPv6Any). Attempting to bind to http://0.0.0.0:{port} instead.
/// </summary>
@ -38,6 +430,468 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
internal static string FormatResponseStreamWasUpgraded()
=> GetString("ResponseStreamWasUpgraded");
/// <summary>
/// Kestrel does not support big-endian architectures.
/// </summary>
internal static string BigEndianNotSupported
{
get => GetString("BigEndianNotSupported");
}
/// <summary>
/// Kestrel does not support big-endian architectures.
/// </summary>
internal static string FormatBigEndianNotSupported()
=> GetString("BigEndianNotSupported");
/// <summary>
/// Maximum request buffer size ({requestBufferSize}) must be greater than or equal to maximum request header size ({requestHeaderSize}).
/// </summary>
internal static string MaxRequestBufferSmallerThanRequestHeaderBuffer
{
get => GetString("MaxRequestBufferSmallerThanRequestHeaderBuffer");
}
/// <summary>
/// Maximum request buffer size ({requestBufferSize}) must be greater than or equal to maximum request header size ({requestHeaderSize}).
/// </summary>
internal static string FormatMaxRequestBufferSmallerThanRequestHeaderBuffer(object requestBufferSize, object requestHeaderSize)
=> string.Format(CultureInfo.CurrentCulture, GetString("MaxRequestBufferSmallerThanRequestHeaderBuffer", "requestBufferSize", "requestHeaderSize"), requestBufferSize, requestHeaderSize);
/// <summary>
/// Maximum request buffer size ({requestBufferSize}) must be greater than or equal to maximum request line size ({requestLineSize}).
/// </summary>
internal static string MaxRequestBufferSmallerThanRequestLineBuffer
{
get => GetString("MaxRequestBufferSmallerThanRequestLineBuffer");
}
/// <summary>
/// Maximum request buffer size ({requestBufferSize}) must be greater than or equal to maximum request line size ({requestLineSize}).
/// </summary>
internal static string FormatMaxRequestBufferSmallerThanRequestLineBuffer(object requestBufferSize, object requestLineSize)
=> string.Format(CultureInfo.CurrentCulture, GetString("MaxRequestBufferSmallerThanRequestLineBuffer", "requestBufferSize", "requestLineSize"), requestBufferSize, requestLineSize);
/// <summary>
/// Server has already started.
/// </summary>
internal static string ServerAlreadyStarted
{
get => GetString("ServerAlreadyStarted");
}
/// <summary>
/// Server has already started.
/// </summary>
internal static string FormatServerAlreadyStarted()
=> GetString("ServerAlreadyStarted");
/// <summary>
/// Unknown transport mode: '{mode}'.
/// </summary>
internal static string UnknownTransportMode
{
get => GetString("UnknownTransportMode");
}
/// <summary>
/// Unknown transport mode: '{mode}'.
/// </summary>
internal static string FormatUnknownTransportMode(object mode)
=> string.Format(CultureInfo.CurrentCulture, GetString("UnknownTransportMode", "mode"), mode);
/// <summary>
/// Invalid non-ASCII or control character in header: {character}
/// </summary>
internal static string InvalidAsciiOrControlChar
{
get => GetString("InvalidAsciiOrControlChar");
}
/// <summary>
/// Invalid non-ASCII or control character in header: {character}
/// </summary>
internal static string FormatInvalidAsciiOrControlChar(object character)
=> string.Format(CultureInfo.CurrentCulture, GetString("InvalidAsciiOrControlChar", "character"), character);
/// <summary>
/// Invalid Content-Length: "{value}". Value must be a positive integral number.
/// </summary>
internal static string InvalidContentLength_InvalidNumber
{
get => GetString("InvalidContentLength_InvalidNumber");
}
/// <summary>
/// Invalid Content-Length: "{value}". Value must be a positive integral number.
/// </summary>
internal static string FormatInvalidContentLength_InvalidNumber(object value)
=> string.Format(CultureInfo.CurrentCulture, GetString("InvalidContentLength_InvalidNumber", "value"), value);
/// <summary>
/// Value must be null or a non-negative integer.
/// </summary>
internal static string NonNegativeNullableIntRequired
{
get => GetString("NonNegativeNullableIntRequired");
}
/// <summary>
/// Value must be null or a non-negative integer.
/// </summary>
internal static string FormatNonNegativeNullableIntRequired()
=> GetString("NonNegativeNullableIntRequired");
/// <summary>
/// Value must be a positive integer.
/// </summary>
internal static string PositiveIntRequired
{
get => GetString("PositiveIntRequired");
}
/// <summary>
/// Value must be a positive integer.
/// </summary>
internal static string FormatPositiveIntRequired()
=> GetString("PositiveIntRequired");
/// <summary>
/// Value must be null or a positive integer.
/// </summary>
internal static string PositiveNullableIntRequired
{
get => GetString("PositiveNullableIntRequired");
}
/// <summary>
/// Value must be null or a positive integer.
/// </summary>
internal static string FormatPositiveNullableIntRequired()
=> GetString("PositiveNullableIntRequired");
/// <summary>
/// Unix socket path must be absolute.
/// </summary>
internal static string UnixSocketPathMustBeAbsolute
{
get => GetString("UnixSocketPathMustBeAbsolute");
}
/// <summary>
/// Unix socket path must be absolute.
/// </summary>
internal static string FormatUnixSocketPathMustBeAbsolute()
=> GetString("UnixSocketPathMustBeAbsolute");
/// <summary>
/// Failed to bind to address {address}.
/// </summary>
internal static string AddressBindingFailed
{
get => GetString("AddressBindingFailed");
}
/// <summary>
/// Failed to bind to address {address}.
/// </summary>
internal static string FormatAddressBindingFailed(object address)
=> string.Format(CultureInfo.CurrentCulture, GetString("AddressBindingFailed", "address"), address);
/// <summary>
/// No listening endpoints were configured. Binding to {address} by default.
/// </summary>
internal static string BindingToDefaultAddress
{
get => GetString("BindingToDefaultAddress");
}
/// <summary>
/// No listening endpoints were configured. Binding to {address} by default.
/// </summary>
internal static string FormatBindingToDefaultAddress(object address)
=> string.Format(CultureInfo.CurrentCulture, GetString("BindingToDefaultAddress", "address"), address);
/// <summary>
/// HTTPS endpoints can only be configured using {methodName}.
/// </summary>
internal static string ConfigureHttpsFromMethodCall
{
get => GetString("ConfigureHttpsFromMethodCall");
}
/// <summary>
/// HTTPS endpoints can only be configured using {methodName}.
/// </summary>
internal static string FormatConfigureHttpsFromMethodCall(object methodName)
=> string.Format(CultureInfo.CurrentCulture, GetString("ConfigureHttpsFromMethodCall", "methodName"), methodName);
/// <summary>
/// A path base can only be configured using {methodName}.
/// </summary>
internal static string ConfigurePathBaseFromMethodCall
{
get => GetString("ConfigurePathBaseFromMethodCall");
}
/// <summary>
/// A path base can only be configured using {methodName}.
/// </summary>
internal static string FormatConfigurePathBaseFromMethodCall(object methodName)
=> string.Format(CultureInfo.CurrentCulture, GetString("ConfigurePathBaseFromMethodCall", "methodName"), methodName);
/// <summary>
/// Dynamic port binding is not supported when binding to localhost. You must either bind to 127.0.0.1:0 or [::1]:0, or both.
/// </summary>
internal static string DynamicPortOnLocalhostNotSupported
{
get => GetString("DynamicPortOnLocalhostNotSupported");
}
/// <summary>
/// Dynamic port binding is not supported when binding to localhost. You must either bind to 127.0.0.1:0 or [::1]:0, or both.
/// </summary>
internal static string FormatDynamicPortOnLocalhostNotSupported()
=> GetString("DynamicPortOnLocalhostNotSupported");
/// <summary>
/// Failed to bind to address {endpoint}: address already in use.
/// </summary>
internal static string EndpointAlreadyInUse
{
get => GetString("EndpointAlreadyInUse");
}
/// <summary>
/// Failed to bind to address {endpoint}: address already in use.
/// </summary>
internal static string FormatEndpointAlreadyInUse(object endpoint)
=> string.Format(CultureInfo.CurrentCulture, GetString("EndpointAlreadyInUse", "endpoint"), endpoint);
/// <summary>
/// Invalid URL: '{url}'.
/// </summary>
internal static string InvalidUrl
{
get => GetString("InvalidUrl");
}
/// <summary>
/// Invalid URL: '{url}'.
/// </summary>
internal static string FormatInvalidUrl(object url)
=> string.Format(CultureInfo.CurrentCulture, GetString("InvalidUrl", "url"), url);
/// <summary>
/// Unable to bind to {address} on the {interfaceName} interface: '{error}'.
/// </summary>
internal static string NetworkInterfaceBindingFailed
{
get => GetString("NetworkInterfaceBindingFailed");
}
/// <summary>
/// Unable to bind to {address} on the {interfaceName} interface: '{error}'.
/// </summary>
internal static string FormatNetworkInterfaceBindingFailed(object address, object interfaceName, object error)
=> string.Format(CultureInfo.CurrentCulture, GetString("NetworkInterfaceBindingFailed", "address", "interfaceName", "error"), address, interfaceName, error);
/// <summary>
/// Overriding address(es) '{addresses}'. Binding to endpoints defined in {methodName} instead.
/// </summary>
internal static string OverridingWithKestrelOptions
{
get => GetString("OverridingWithKestrelOptions");
}
/// <summary>
/// Overriding address(es) '{addresses}'. Binding to endpoints defined in {methodName} instead.
/// </summary>
internal static string FormatOverridingWithKestrelOptions(object addresses, object methodName)
=> string.Format(CultureInfo.CurrentCulture, GetString("OverridingWithKestrelOptions", "addresses", "methodName"), addresses, methodName);
/// <summary>
/// Overriding endpoints defined in UseKestrel() because {settingName} is set to true. Binding to address(es) '{addresses}' instead.
/// </summary>
internal static string OverridingWithPreferHostingUrls
{
get => GetString("OverridingWithPreferHostingUrls");
}
/// <summary>
/// Overriding endpoints defined in UseKestrel() because {settingName} is set to true. Binding to address(es) '{addresses}' instead.
/// </summary>
internal static string FormatOverridingWithPreferHostingUrls(object settingName, object addresses)
=> string.Format(CultureInfo.CurrentCulture, GetString("OverridingWithPreferHostingUrls", "settingName", "addresses"), settingName, addresses);
/// <summary>
/// Unrecognized scheme in server address '{address}'. Only 'http://' is supported.
/// </summary>
internal static string UnsupportedAddressScheme
{
get => GetString("UnsupportedAddressScheme");
}
/// <summary>
/// Unrecognized scheme in server address '{address}'. Only 'http://' is supported.
/// </summary>
internal static string FormatUnsupportedAddressScheme(object address)
=> string.Format(CultureInfo.CurrentCulture, GetString("UnsupportedAddressScheme", "address"), address);
/// <summary>
/// Headers are read-only, response has already started.
/// </summary>
internal static string HeadersAreReadOnly
{
get => GetString("HeadersAreReadOnly");
}
/// <summary>
/// Headers are read-only, response has already started.
/// </summary>
internal static string FormatHeadersAreReadOnly()
=> GetString("HeadersAreReadOnly");
/// <summary>
/// An item with the same key has already been added.
/// </summary>
internal static string KeyAlreadyExists
{
get => GetString("KeyAlreadyExists");
}
/// <summary>
/// An item with the same key has already been added.
/// </summary>
internal static string FormatKeyAlreadyExists()
=> GetString("KeyAlreadyExists");
/// <summary>
/// Setting the header {name} is not allowed on responses with status code {statusCode}.
/// </summary>
internal static string HeaderNotAllowedOnResponse
{
get => GetString("HeaderNotAllowedOnResponse");
}
/// <summary>
/// Setting the header {name} is not allowed on responses with status code {statusCode}.
/// </summary>
internal static string FormatHeaderNotAllowedOnResponse(object name, object statusCode)
=> string.Format(CultureInfo.CurrentCulture, GetString("HeaderNotAllowedOnResponse", "name", "statusCode"), name, statusCode);
/// <summary>
/// {name} cannot be set because the response has already started.
/// </summary>
internal static string ParameterReadOnlyAfterResponseStarted
{
get => GetString("ParameterReadOnlyAfterResponseStarted");
}
/// <summary>
/// {name} cannot be set because the response has already started.
/// </summary>
internal static string FormatParameterReadOnlyAfterResponseStarted(object name)
=> string.Format(CultureInfo.CurrentCulture, GetString("ParameterReadOnlyAfterResponseStarted", "name"), name);
/// <summary>
/// Request processing didn't complete within the shutdown timeout.
/// </summary>
internal static string RequestProcessingAborted
{
get => GetString("RequestProcessingAborted");
}
/// <summary>
/// Request processing didn't complete within the shutdown timeout.
/// </summary>
internal static string FormatRequestProcessingAborted()
=> GetString("RequestProcessingAborted");
/// <summary>
/// Response Content-Length mismatch: too few bytes written ({written} of {expected}).
/// </summary>
internal static string TooFewBytesWritten
{
get => GetString("TooFewBytesWritten");
}
/// <summary>
/// Response Content-Length mismatch: too few bytes written ({written} of {expected}).
/// </summary>
internal static string FormatTooFewBytesWritten(object written, object expected)
=> string.Format(CultureInfo.CurrentCulture, GetString("TooFewBytesWritten", "written", "expected"), written, expected);
/// <summary>
/// Response Content-Length mismatch: too many bytes written ({written} of {expected}).
/// </summary>
internal static string TooManyBytesWritten
{
get => GetString("TooManyBytesWritten");
}
/// <summary>
/// Response Content-Length mismatch: too many bytes written ({written} of {expected}).
/// </summary>
internal static string FormatTooManyBytesWritten(object written, object expected)
=> string.Format(CultureInfo.CurrentCulture, GetString("TooManyBytesWritten", "written", "expected"), written, expected);
/// <summary>
/// The response has been aborted due to an unhandled application exception.
/// </summary>
internal static string UnhandledApplicationException
{
get => GetString("UnhandledApplicationException");
}
/// <summary>
/// The response has been aborted due to an unhandled application exception.
/// </summary>
internal static string FormatUnhandledApplicationException()
=> GetString("UnhandledApplicationException");
/// <summary>
/// Writing to the response body is invalid for responses with status code {statusCode}.
/// </summary>
internal static string WritingToResponseBodyNotSupported
{
get => GetString("WritingToResponseBodyNotSupported");
}
/// <summary>
/// Writing to the response body is invalid for responses with status code {statusCode}.
/// </summary>
internal static string FormatWritingToResponseBodyNotSupported(object statusCode)
=> string.Format(CultureInfo.CurrentCulture, GetString("WritingToResponseBodyNotSupported", "statusCode"), statusCode);
/// <summary>
/// Connection shutdown abnormally.
/// </summary>
internal static string ConnectionShutdownError
{
get => GetString("ConnectionShutdownError");
}
/// <summary>
/// Connection shutdown abnormally.
/// </summary>
internal static string FormatConnectionShutdownError()
=> GetString("ConnectionShutdownError");
/// <summary>
/// Connection processing ended abnormally.
/// </summary>
internal static string RequestProcessingEndError
{
get => GetString("RequestProcessingEndError");
}
/// <summary>
/// Connection processing ended abnormally.
/// </summary>
internal static string FormatRequestProcessingEndError()
=> GetString("RequestProcessingEndError");
private static string GetString(string name, params string[] formatterNames)
{
var value = _resourceManager.GetString(name);

View File

@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
int schemeDelimiterStart = url.IndexOf("://", StringComparison.Ordinal);
if (schemeDelimiterStart < 0)
{
throw new FormatException($"Invalid URL: {url}");
throw new FormatException(CoreStrings.FormatInvalidUrl(url));
}
int schemeDelimiterEnd = schemeDelimiterStart + "://".Length;
@ -134,7 +134,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
if (string.IsNullOrEmpty(serverAddress.Host))
{
throw new FormatException($"Invalid URL: {url}");
throw new FormatException(CoreStrings.FormatInvalidUrl(url));
}
if (url[url.Length - 1] == '/')

View File

@ -31,9 +31,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https
{
throw new ArgumentNullException(nameof(options));
}
if (options.ServerCertificate == null)
{
throw new ArgumentException("The server certificate parameter is required.");
throw new ArgumentException(HttpsStrings.ServiceCertificateRequired, nameof(options));
}
_options = options;
@ -97,7 +98,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https
}
catch (IOException ex)
{
_logger?.LogInformation(1, ex, "Failed to authenticate HTTPS connection.");
_logger?.LogInformation(1, ex, HttpsStrings.AuthenticationFailed);
sslStream.Dispose();
return _closedAdaptedConnection;
}

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
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
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<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
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
mimetype set.
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
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
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
: 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
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AuthenticationFailed" xml:space="preserve">
<value>Failed to authenticate HTTPS connection.</value>
</data>
<data name="ServiceCertificateRequired" xml:space="preserve">
<value>The server certificate parameter is required.</value>
</data>
</root>

View File

@ -24,4 +24,10 @@
<PackageReference Include="System.Net.Security" Version="$(CoreFxVersion)" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="HttpsStrings.resx">
<Generator></Generator>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,58 @@
// <auto-generated />
namespace Microsoft.AspNetCore.Server.Kestrel.Https
{
using System.Globalization;
using System.Reflection;
using System.Resources;
internal static class HttpsStrings
{
private static readonly ResourceManager _resourceManager
= new ResourceManager("Microsoft.AspNetCore.Server.Kestrel.Https.HttpsStrings", typeof(HttpsStrings).GetTypeInfo().Assembly);
/// <summary>
/// Failed to authenticate HTTPS connection.
/// </summary>
internal static string AuthenticationFailed
{
get => GetString("AuthenticationFailed");
}
/// <summary>
/// Failed to authenticate HTTPS connection.
/// </summary>
internal static string FormatAuthenticationFailed()
=> GetString("AuthenticationFailed");
/// <summary>
/// The server certificate parameter is required.
/// </summary>
internal static string ServiceCertificateRequired
{
get => GetString("ServiceCertificateRequired");
}
/// <summary>
/// The server certificate parameter is required.
/// </summary>
internal static string FormatServiceCertificateRequired()
=> GetString("ServiceCertificateRequired");
private static string GetString(string name, params string[] formatterNames)
{
var value = _resourceManager.GetString(name);
System.Diagnostics.Debug.Assert(value != null);
if (formatterNames != null)
{
for (var i = 0; i < formatterNames.Length; i++)
{
value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
}
}
return value;
}
}
}

View File

@ -21,4 +21,10 @@
<ProjectReference Include="..\Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions\Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="SocketsStrings.resx">
<Generator></Generator>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,58 @@
// <auto-generated />
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
{
using System.Globalization;
using System.Reflection;
using System.Resources;
internal static class SocketsStrings
{
private static readonly ResourceManager _resourceManager
= new ResourceManager("Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketsStrings", typeof(SocketsStrings).GetTypeInfo().Assembly);
/// <summary>
/// Only ListenType.IPEndPoint is supported.
/// </summary>
internal static string OnlyIPEndPointsSupported
{
get => GetString("OnlyIPEndPointsSupported");
}
/// <summary>
/// Only ListenType.IPEndPoint is supported.
/// </summary>
internal static string FormatOnlyIPEndPointsSupported()
=> GetString("OnlyIPEndPointsSupported");
/// <summary>
/// Transport is already bound.
/// </summary>
internal static string TransportAlreadyBound
{
get => GetString("TransportAlreadyBound");
}
/// <summary>
/// Transport is already bound.
/// </summary>
internal static string FormatTransportAlreadyBound()
=> GetString("TransportAlreadyBound");
private static string GetString(string name, params string[] formatterNames)
{
var value = _resourceManager.GetString(name);
System.Diagnostics.Debug.Assert(value != null);
if (formatterNames != null)
{
for (var i = 0; i < formatterNames.Length; i++)
{
value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
}
}
return value;
}
}
}

View File

@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
{
if (_listenSocket != null)
{
throw new InvalidOperationException("Transport is already bound");
throw new InvalidOperationException(SocketsStrings.TransportAlreadyBound);
}
IPEndPoint endPoint = _endPointInformation.IPEndPoint;

View File

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
if (endPointInformation.Type != ListenType.IPEndPoint)
{
throw new ArgumentException("Only ListenType.IPEndPoint is supported", nameof(endPointInformation));
throw new ArgumentException(SocketsStrings.OnlyIPEndPointsSupported, nameof(endPointInformation));
}
if (handler == null)

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
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
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<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
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
mimetype set.
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
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
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
: 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
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="OnlyIPEndPointsSupported" xml:space="preserve">
<value>Only ListenType.IPEndPoint is supported.</value>
</data>
<data name="TransportAlreadyBound" xml:space="preserve">
<value>Transport is already bound.</value>
</data>
</root>

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Globalization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Primitives;
using Xunit;
@ -149,7 +148,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var dictionary = (IDictionary<string, StringValues>)headers;
var exception = Assert.Throws<InvalidOperationException>(() => dictionary.Add("Content-Length", new[] { contentLength }));
Assert.Equal($"Invalid Content-Length: \"{contentLength}\". Value must be a positive integral number.", exception.Message);
Assert.Equal(CoreStrings.FormatInvalidContentLength_InvalidNumber(contentLength), exception.Message);
}
[Theory]
@ -160,7 +159,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var dictionary = (IDictionary<string, StringValues>)headers;
var exception = Assert.Throws<InvalidOperationException>(() => ((IHeaderDictionary)headers)["Content-Length"] = contentLength);
Assert.Equal($"Invalid Content-Length: \"{contentLength}\". Value must be a positive integral number.", exception.Message);
Assert.Equal(CoreStrings.FormatInvalidContentLength_InvalidNumber(contentLength), exception.Message);
}
[Theory]
@ -170,7 +169,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var headers = new FrameResponseHeaders();
var exception = Assert.Throws<InvalidOperationException>(() => headers.HeaderContentLength = contentLength);
Assert.Equal($"Invalid Content-Length: \"{contentLength}\". Value must be a positive integral number.", exception.Message);
Assert.Equal(CoreStrings.FormatInvalidContentLength_InvalidNumber(contentLength), exception.Message);
}
[Theory]

View File

@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var exception = Assert.Throws<BadHttpRequestException>(() => _frame.TakeMessageHeaders(readableBuffer, out _consumed, out _examined));
_input.Reader.Advance(_consumed, _examined);
Assert.Equal("Request headers too long.", exception.Message);
Assert.Equal(CoreStrings.BadRequest_HeadersExceedMaxTotalSize, exception.Message);
Assert.Equal(StatusCodes.Status431RequestHeaderFieldsTooLarge, exception.StatusCode);
}
@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var exception = Assert.Throws<BadHttpRequestException>(() => _frame.TakeMessageHeaders(readableBuffer, out _consumed, out _examined));
_input.Reader.Advance(_consumed, _examined);
Assert.Equal("Request contains too many headers.", exception.Message);
Assert.Equal(CoreStrings.BadRequest_TooManyHeaders, exception.Message);
Assert.Equal(StatusCodes.Status431RequestHeaderFieldsTooLarge, exception.StatusCode);
}
@ -341,7 +341,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var exception = Assert.Throws<BadHttpRequestException>(() => _frame.TakeStartLine(readableBuffer, out _consumed, out _examined));
_input.Reader.Advance(_consumed, _examined);
Assert.Equal("Request line too long.", exception.Message);
Assert.Equal(CoreStrings.BadRequest_RequestLineTooLong, exception.Message);
Assert.Equal(StatusCodes.Status414UriTooLong, exception.StatusCode);
}
@ -356,7 +356,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
_frame.TakeStartLine(readableBuffer, out _consumed, out _examined));
_input.Reader.Advance(_consumed, _examined);
Assert.Equal($"Invalid request target: '{target}'", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_InvalidRequestTarget_Detail(target), exception.Message);
}
[Theory]
@ -370,7 +370,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
_frame.TakeStartLine(readableBuffer, out _consumed, out _examined));
_input.Reader.Advance(_consumed, _examined);
Assert.Equal($"Invalid request target: '{target.EscapeNonPrintable()}'", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_InvalidRequestTarget_Detail(target.EscapeNonPrintable()), exception.Message);
}
[Theory]
@ -386,7 +386,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
_frame.TakeStartLine(readableBuffer, out _consumed, out _examined));
_input.Reader.Advance(_consumed, _examined);
Assert.Equal($"Invalid request line: '{requestLine.EscapeNonPrintable()}'", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_InvalidRequestLine_Detail(requestLine.EscapeNonPrintable()), exception.Message);
}
[Theory]
@ -402,7 +402,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
_frame.TakeStartLine(readableBuffer, out _consumed, out _examined));
_input.Reader.Advance(_consumed, _examined);
Assert.Equal($"Invalid request target: '{target.EscapeNonPrintable()}'", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_InvalidRequestTarget_Detail(target.EscapeNonPrintable()), exception.Message);
}
[Theory]
@ -418,7 +418,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
_frame.TakeStartLine(readableBuffer, out _consumed, out _examined));
_input.Reader.Advance(_consumed, _examined);
Assert.Equal($"Invalid request target: '{target.EscapeNonPrintable()}'", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_InvalidRequestTarget_Detail(target.EscapeNonPrintable()), exception.Message);
}
[Theory]
@ -433,7 +433,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
_input.Reader.Advance(_consumed, _examined);
Assert.Equal(405, exception.StatusCode);
Assert.Equal("Method not allowed.", exception.Message);
Assert.Equal(CoreStrings.BadRequest_MethodNotAllowed, exception.Message);
Assert.Equal(HttpUtilities.MethodToString(allowedMethod), exception.AllowedHeader);
}
@ -629,7 +629,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
_frame.TakeStartLine(readableBuffer, out _consumed, out _examined));
_input.Reader.Advance(_consumed, _examined);
Assert.Equal("Invalid request target: ''", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_InvalidRequestTarget_Detail(string.Empty), exception.Message);
Assert.Equal(StatusCodes.Status400BadRequest, exception.StatusCode);
}
finally

View File

@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var exception = Assert.Throws<BadHttpRequestException>(() =>
parser.ParseRequestLine(requestHandler, buffer, out var consumed, out var examined));
Assert.Equal($"Invalid request line: '{requestLine.EscapeNonPrintable()}'", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_InvalidRequestLine_Detail(requestLine.EscapeNonPrintable()), exception.Message);
Assert.Equal(StatusCodes.Status400BadRequest, (exception as BadHttpRequestException).StatusCode);
}
@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var exception = Assert.Throws<BadHttpRequestException>(() =>
parser.ParseRequestLine(requestHandler, buffer, out var consumed, out var examined));
Assert.Equal($"Invalid request line: '{method.EscapeNonPrintable()} / HTTP/1.1\\x0D\\x0A'", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_InvalidRequestLine_Detail(method.EscapeNonPrintable() + @" / HTTP/1.1\x0D\x0A"), exception.Message);
Assert.Equal(StatusCodes.Status400BadRequest, (exception as BadHttpRequestException).StatusCode);
}
@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var exception = Assert.Throws<BadHttpRequestException>(() =>
parser.ParseRequestLine(requestHandler, buffer, out var consumed, out var examined));
Assert.Equal($"Unrecognized HTTP version: '{httpVersion}'", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_UnrecognizedHTTPVersion(httpVersion), exception.Message);
Assert.Equal(StatusCodes.Status505HttpVersionNotsupported, (exception as BadHttpRequestException).StatusCode);
}
@ -352,7 +352,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
exception = Assert.Throws<BadHttpRequestException>(() =>
parser.ParseRequestLine(requestHandler, buffer, out var consumed, out var examined));
Assert.Equal("Unrecognized HTTP version: ''", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_UnrecognizedHTTPVersion(string.Empty), exception.Message);
Assert.Equal(StatusCodes.Status505HttpVersionNotsupported, (exception as BadHttpRequestException).StatusCode);
// Invalid request header
@ -361,7 +361,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
exception = Assert.Throws<BadHttpRequestException>(() =>
parser.ParseHeaders(requestHandler, buffer, out var consumed, out var examined, out var consumedBytes));
Assert.Equal("Invalid request header: ''", exception.Message);
Assert.Equal(CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(string.Empty), exception.Message);
Assert.Equal(StatusCodes.Status400BadRequest, exception.StatusCode);
}

View File

@ -8,7 +8,6 @@ using System.Threading;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Internal;
@ -110,7 +109,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var exception = Assert.Throws<InvalidOperationException>(() => StartDummyApplication(server));
Assert.Equal(
$"Maximum request buffer size ({maxRequestBufferSize}) must be greater than or equal to maximum request line size ({maxRequestLineSize}).",
CoreStrings.FormatMaxRequestBufferSmallerThanRequestLineBuffer(maxRequestBufferSize, maxRequestLineSize),
exception.Message);
Assert.Equal(1, testLogger.CriticalErrorsLogged);
}
@ -132,7 +131,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var exception = Assert.Throws<InvalidOperationException>(() => StartDummyApplication(server));
Assert.Equal(
$"Maximum request buffer size ({maxRequestBufferSize}) must be greater than or equal to maximum request headers size ({maxRequestHeadersTotalSize}).",
CoreStrings.FormatMaxRequestBufferSmallerThanRequestHeaderBuffer(maxRequestBufferSize, maxRequestHeadersTotalSize),
exception.Message);
Assert.Equal(1, testLogger.CriticalErrorsLogged);
}

View File

@ -231,7 +231,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
MessageBody.For(HttpVersion.Http11, new FrameRequestHeaders { HeaderTransferEncoding = "chunked, not-chunked" }, input.FrameContext));
Assert.Equal(StatusCodes.Status400BadRequest, ex.StatusCode);
Assert.Equal("Final transfer coding is not \"chunked\": \"chunked, not-chunked\"", ex.Message);
Assert.Equal(CoreStrings.FormatBadRequest_FinalTransferCodingNotChunked("chunked, not-chunked"), ex.Message);
}
}
@ -247,7 +247,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
MessageBody.For(HttpVersion.Http11, new FrameRequestHeaders(), input.FrameContext));
Assert.Equal(StatusCodes.Status411LengthRequired, ex.StatusCode);
Assert.Equal($"{method} request contains no Content-Length or Transfer-Encoding header", ex.Message);
Assert.Equal(CoreStrings.FormatBadRequest_LengthRequired(method), ex.Message);
}
}
@ -263,7 +263,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
MessageBody.For(HttpVersion.Http10, new FrameRequestHeaders(), input.FrameContext));
Assert.Equal(StatusCodes.Status400BadRequest, ex.StatusCode);
Assert.Equal($"{method} request contains no Content-Length header", ex.Message);
Assert.Equal(CoreStrings.FormatBadRequest_LengthRequiredHttp10(method), ex.Message);
}
}

View File

@ -200,7 +200,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
Assert.Equal(5000, host.GetPort());
Assert.Single(testLogger.Messages, log => log.LogLevel == LogLevel.Debug &&
string.Equals($"No listening endpoints were configured. Binding to {Constants.DefaultServerAddress} by default.",
string.Equals(CoreStrings.FormatBindingToDefaultAddress(Constants.DefaultServerAddress),
log.Message, StringComparison.Ordinal));
foreach (var address in addresses)
@ -227,7 +227,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
using (var host = hostBuilder.Build())
{
var exception = Assert.Throws<IOException>(() => host.Start());
Assert.Equal($"Failed to bind to address http://127.0.0.1:{port}: address already in use.", exception.Message);
Assert.Equal(CoreStrings.FormatEndpointAlreadyInUse($"http://127.0.0.1:{port}"), exception.Message);
}
}
}
@ -250,7 +250,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
using (var host = hostBuilder.Build())
{
var exception = Assert.Throws<IOException>(() => host.Start());
Assert.Equal($"Failed to bind to address http://[::1]:{port}: address already in use.", exception.Message);
Assert.Equal(CoreStrings.FormatEndpointAlreadyInUse($"http://[::1]:{port}"), exception.Message);
}
}
}
@ -277,7 +277,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
Assert.Equal(overrideAddressPort, host.GetPort());
Assert.Single(testLogger.Messages, log => log.LogLevel == LogLevel.Information &&
string.Equals($"Overriding endpoints defined in UseKestrel() since {nameof(IServerAddressesFeature.PreferHostingUrls)} is set to true. Binding to address(es) '{overrideAddress}' instead.",
string.Equals(CoreStrings.FormatOverridingWithPreferHostingUrls(nameof(IServerAddressesFeature.PreferHostingUrls), overrideAddress),
log.Message, StringComparison.Ordinal));
Assert.Equal(new Uri(overrideAddress).ToString(), await HttpClientSlim.GetStringAsync(overrideAddress));
@ -389,7 +389,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
{
var exception = Assert.Throws<IOException>(() => host.Start());
Assert.Equal(
$"Failed to bind to address http://{(addressFamily == AddressFamily.InterNetwork ? "127.0.0.1" : "[::1]")}:{port}: address already in use.",
CoreStrings.FormatEndpointAlreadyInUse($"http://{(addressFamily == AddressFamily.InterNetwork ? "127.0.0.1" : "[::1]")}:{port}"),
exception.Message);
}
}
@ -677,21 +677,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
_portSupported = new Lazy<bool>(CanBindToPort);
}
public bool IsMet
{
get
{
return _portSupported.Value;
}
}
public bool IsMet => _portSupported.Value;
public string SkipReason
{
get
{
return $"Cannot bind to port {_port} on the host.";
}
}
public string SkipReason => $"Cannot bind to port {_port} on the host.";
private bool CanBindToPort()
{

View File

@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
return TestBadRequest(
$"GET / {httpVersion}\r\n",
"505 HTTP Version Not Supported",
$"Unrecognized HTTP version: '{httpVersion}'");
CoreStrings.FormatBadRequest_UnrecognizedHTTPVersion(httpVersion));
}
[Theory]
@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
return TestBadRequest(
$"{method} / HTTP/1.1\r\nHost:\r\n\r\n",
"411 Length Required",
$"{method} request contains no Content-Length or Transfer-Encoding header");
CoreStrings.FormatBadRequest_LengthRequired(method));
}
[Theory]
@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
return TestBadRequest(
$"{method} / HTTP/1.0\r\n\r\n",
"400 Bad Request",
$"{method} request contains no Content-Length header");
CoreStrings.FormatBadRequest_LengthRequiredHttp10(method));
}
[Theory]
@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
return TestBadRequest(
$"POST / HTTP/1.1\r\nHost:\r\nContent-Length: {contentLength}\r\n\r\n",
"400 Bad Request",
$"Invalid content length: {contentLength}");
CoreStrings.FormatBadRequest_InvalidContentLength_Detail(contentLength));
}
[Theory]
@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
return TestBadRequest(
$"{request} HTTP/1.1\r\n",
"405 Method Not Allowed",
"Method not allowed.",
CoreStrings.BadRequest_MethodNotAllowed,
$"Allow: {allowedMethod}");
}
@ -112,7 +112,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
return TestBadRequest(
"GET / HTTP/1.1\r\n\r\n",
"400 Bad Request",
"Request is missing Host header.");
CoreStrings.BadRequest_MissingHostHeader);
}
[Fact]
@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
{
return TestBadRequest("GET / HTTP/1.1\r\nHost: localhost\r\nHost: localhost\r\n\r\n",
"400 Bad Request",
"Multiple Host headers.");
CoreStrings.BadRequest_MultipleHostHeaders);
}
[Theory]
@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
return TestBadRequest(
$"{requestTarget} HTTP/1.1\r\nHost: {host}\r\n\r\n",
"400 Bad Request",
$"Invalid Host header: '{host.Trim()}'");
CoreStrings.FormatBadRequest_InvalidHostHeader_Detail(host.Trim()));
}
[Fact]
@ -218,17 +218,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
foreach (var requestLine in HttpParsingData.RequestLineInvalidData)
{
data.Add(requestLine, $"Invalid request line: '{requestLine.EscapeNonPrintable()}'");
data.Add(requestLine, CoreStrings.FormatBadRequest_InvalidRequestLine_Detail(requestLine.EscapeNonPrintable()));
}
foreach (var target in HttpParsingData.TargetWithEncodedNullCharData)
{
data.Add($"GET {target} HTTP/1.1\r\n", $"Invalid request target: '{target.EscapeNonPrintable()}'");
data.Add($"GET {target} HTTP/1.1\r\n", CoreStrings.FormatBadRequest_InvalidRequestTarget_Detail(target.EscapeNonPrintable()));
}
foreach (var target in HttpParsingData.TargetWithNullCharData)
{
data.Add($"GET {target} HTTP/1.1\r\n", $"Invalid request target: '{target.EscapeNonPrintable()}'");
data.Add($"GET {target} HTTP/1.1\r\n", CoreStrings.FormatBadRequest_InvalidRequestTarget_Detail(target.EscapeNonPrintable()));
}
return data;
@ -239,6 +239,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
public static IEnumerable<object[]> InvalidRequestHeaderData => HttpParsingData.RequestHeaderInvalidData;
public static TheoryData<string,string> InvalidHostHeaderData => HttpParsingData.HostHeaderInvalidData;
public static TheoryData<string, string> InvalidHostHeaderData => HttpParsingData.HostHeaderInvalidData;
}
}

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Xunit;
@ -356,76 +357,76 @@ namespace Microsoft.AspNetCore.Testing
public static IEnumerable<object[]> RequestHeaderInvalidData => new[]
{
// Missing CR
new[] { "Header: value\n\r\n", @"Invalid request header: 'Header: value\x0A'" },
new[] { "Header-1: value1\nHeader-2: value2\r\n\r\n", @"Invalid request header: 'Header-1: value1\x0A'" },
new[] { "Header-1: value1\r\nHeader-2: value2\n\r\n", @"Invalid request header: 'Header-2: value2\x0A'" },
new[] { "Header: value\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header: value\x0A") },
new[] { "Header-1: value1\nHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: value1\x0A") },
new[] { "Header-1: value1\r\nHeader-2: value2\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-2: value2\x0A") },
// Line folding
new[] { "Header: line1\r\n line2\r\n\r\n", @"Invalid request header: ' line2\x0D\x0A'" },
new[] { "Header: line1\r\n\tline2\r\n\r\n", @"Invalid request header: '\x09line2\x0D\x0A'" },
new[] { "Header: line1\r\n line2\r\n\r\n", @"Invalid request header: ' line2\x0D\x0A'" },
new[] { "Header: line1\r\n \tline2\r\n\r\n", @"Invalid request header: ' \x09line2\x0D\x0A'" },
new[] { "Header: line1\r\n\t line2\r\n\r\n", @"Invalid request header: '\x09 line2\x0D\x0A'" },
new[] { "Header: line1\r\n\t\tline2\r\n\r\n", @"Invalid request header: '\x09\x09line2\x0D\x0A'" },
new[] { "Header: line1\r\n \t\t line2\r\n\r\n", @"Invalid request header: ' \x09\x09 line2\x0D\x0A'" },
new[] { "Header: line1\r\n \t \t line2\r\n\r\n", @"Invalid request header: ' \x09 \x09 line2\x0D\x0A'" },
new[] { "Header-1: multi\r\n line\r\nHeader-2: value2\r\n\r\n", @"Invalid request header: ' line\x0D\x0A'" },
new[] { "Header-1: value1\r\nHeader-2: multi\r\n line\r\n\r\n", @"Invalid request header: ' line\x0D\x0A'" },
new[] { "Header-1: value1\r\n Header-2: value2\r\n\r\n", @"Invalid request header: ' Header-2: value2\x0D\x0A'" },
new[] { "Header-1: value1\r\n\tHeader-2: value2\r\n\r\n", @"Invalid request header: '\x09Header-2: value2\x0D\x0A'" },
new[] { "Header: line1\r\n line2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" line2\x0D\x0A") },
new[] { "Header: line1\r\n\tline2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"\x09line2\x0D\x0A") },
new[] { "Header: line1\r\n line2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" line2\x0D\x0A") },
new[] { "Header: line1\r\n \tline2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" \x09line2\x0D\x0A") },
new[] { "Header: line1\r\n\t line2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"\x09 line2\x0D\x0A") },
new[] { "Header: line1\r\n\t\tline2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"\x09\x09line2\x0D\x0A") },
new[] { "Header: line1\r\n \t\t line2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" \x09\x09 line2\x0D\x0A") },
new[] { "Header: line1\r\n \t \t line2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" \x09 \x09 line2\x0D\x0A") },
new[] { "Header-1: multi\r\n line\r\nHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" line\x0D\x0A") },
new[] { "Header-1: value1\r\nHeader-2: multi\r\n line\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" line\x0D\x0A") },
new[] { "Header-1: value1\r\n Header-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" Header-2: value2\x0D\x0A") },
new[] { "Header-1: value1\r\n\tHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"\x09Header-2: value2\x0D\x0A") },
// CR in value
new[] { "Header-1: value1\r\r\n", @"Invalid request header: 'Header-1: value1\x0D\x0D\x0A'" },
new[] { "Header-1: val\rue1\r\n", @"Invalid request header: 'Header-1: val\x0Due1\x0D\x0A'" },
new[] { "Header-1: value1\rHeader-2: value2\r\n\r\n", @"Invalid request header: 'Header-1: value1\x0DHeader-2: value2\x0D\x0A'" },
new[] { "Header-1: value1\r\nHeader-2: value2\r\r\n", @"Invalid request header: 'Header-2: value2\x0D\x0D\x0A'" },
new[] { "Header-1: value1\r\nHeader-2: v\ralue2\r\n", @"Invalid request header: 'Header-2: v\x0Dalue2\x0D\x0A'" },
new[] { "Header-1: Value__\rVector16________Vector32\r\n", @"Invalid request header: 'Header-1: Value__\x0DVector16________Vector32\x0D\x0A'" },
new[] { "Header-1: Value___Vector16\r________Vector32\r\n", @"Invalid request header: 'Header-1: Value___Vector16\x0D________Vector32\x0D\x0A'" },
new[] { "Header-1: Value___Vector16_______\rVector32\r\n", @"Invalid request header: 'Header-1: Value___Vector16_______\x0DVector32\x0D\x0A'" },
new[] { "Header-1: Value___Vector16________Vector32\r\r\n", @"Invalid request header: 'Header-1: Value___Vector16________Vector32\x0D\x0D\x0A'" },
new[] { "Header-1: Value___Vector16________Vector32_\r\r\n", @"Invalid request header: 'Header-1: Value___Vector16________Vector32_\x0D\x0D\x0A'" },
new[] { "Header-1: Value___Vector16________Vector32Value___Vector16_______\rVector32\r\n", @"Invalid request header: 'Header-1: Value___Vector16________Vector32Value___Vector16_______\x0DVector32\x0D\x0A'" },
new[] { "Header-1: Value___Vector16________Vector32Value___Vector16________Vector32\r\r\n", @"Invalid request header: 'Header-1: Value___Vector16________Vector32Value___Vector16________Vector32\x0D\x0D\x0A'" },
new[] { "Header-1: Value___Vector16________Vector32Value___Vector16________Vector32_\r\r\n", @"Invalid request header: 'Header-1: Value___Vector16________Vector32Value___Vector16________Vector32_\x0D\x0D\x0A'" },
new[] { "Header-1: value1\r\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: value1\x0D\x0D\x0A") },
new[] { "Header-1: val\rue1\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: val\x0Due1\x0D\x0A") },
new[] { "Header-1: value1\rHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: value1\x0DHeader-2: value2\x0D\x0A") },
new[] { "Header-1: value1\r\nHeader-2: value2\r\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-2: value2\x0D\x0D\x0A") },
new[] { "Header-1: value1\r\nHeader-2: v\ralue2\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-2: v\x0Dalue2\x0D\x0A") },
new[] { "Header-1: Value__\rVector16________Vector32\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: Value__\x0DVector16________Vector32\x0D\x0A") },
new[] { "Header-1: Value___Vector16\r________Vector32\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: Value___Vector16\x0D________Vector32\x0D\x0A") },
new[] { "Header-1: Value___Vector16_______\rVector32\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: Value___Vector16_______\x0DVector32\x0D\x0A") },
new[] { "Header-1: Value___Vector16________Vector32\r\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: Value___Vector16________Vector32\x0D\x0D\x0A") },
new[] { "Header-1: Value___Vector16________Vector32_\r\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: Value___Vector16________Vector32_\x0D\x0D\x0A") },
new[] { "Header-1: Value___Vector16________Vector32Value___Vector16_______\rVector32\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: Value___Vector16________Vector32Value___Vector16_______\x0DVector32\x0D\x0A") },
new[] { "Header-1: Value___Vector16________Vector32Value___Vector16________Vector32\r\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: Value___Vector16________Vector32Value___Vector16________Vector32\x0D\x0D\x0A") },
new[] { "Header-1: Value___Vector16________Vector32Value___Vector16________Vector32_\r\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1: Value___Vector16________Vector32Value___Vector16________Vector32_\x0D\x0D\x0A") },
// Missing colon
new[] { "Header-1 value1\r\n\r\n", @"Invalid request header: 'Header-1 value1\x0D\x0A'" },
new[] { "Header-1 value1\r\nHeader-2: value2\r\n\r\n", @"Invalid request header: 'Header-1 value1\x0D\x0A'" },
new[] { "Header-1: value1\r\nHeader-2 value2\r\n\r\n", @"Invalid request header: 'Header-2 value2\x0D\x0A'" },
new[] { "\n", @"Invalid request header: '\x0A'" },
new[] { "Header-1 value1\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1 value1\x0D\x0A") },
new[] { "Header-1 value1\r\nHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-1 value1\x0D\x0A") },
new[] { "Header-1: value1\r\nHeader-2 value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-2 value2\x0D\x0A") },
new[] { "\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"\x0A") },
// Starting with whitespace
new[] { " Header: value\r\n\r\n", @"Invalid request header: ' Header: value\x0D\x0A'" },
new[] { "\tHeader: value\r\n\r\n", @"Invalid request header: '\x09Header: value\x0D\x0A'" },
new[] { " Header-1: value1\r\nHeader-2: value2\r\n\r\n", @"Invalid request header: ' Header-1: value1\x0D\x0A'" },
new[] { "\tHeader-1: value1\r\nHeader-2: value2\r\n\r\n", @"Invalid request header: '\x09Header-1: value1\x0D\x0A'" },
new[] { " Header: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" Header: value\x0D\x0A") },
new[] { "\tHeader: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"\x09Header: value\x0D\x0A") },
new[] { " Header-1: value1\r\nHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@" Header-1: value1\x0D\x0A") },
new[] { "\tHeader-1: value1\r\nHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"\x09Header-1: value1\x0D\x0A") },
// Whitespace in header name
new[] { "Header : value\r\n\r\n", @"Invalid request header: 'Header : value\x0D\x0A'" },
new[] { "Header\t: value\r\n\r\n", @"Invalid request header: 'Header\x09: value\x0D\x0A'" },
new[] { "Header\r: value\r\n\r\n", @"Invalid request header: 'Header\x0D: value\x0D\x0A'" },
new[] { "Header_\rVector16: value\r\n\r\n", @"Invalid request header: 'Header_\x0DVector16: value\x0D\x0A'" },
new[] { "Header__Vector16\r: value\r\n\r\n", @"Invalid request header: 'Header__Vector16\x0D: value\x0D\x0A'" },
new[] { "Header__Vector16_\r: value\r\n\r\n", @"Invalid request header: 'Header__Vector16_\x0D: value\x0D\x0A'" },
new[] { "Header_\rVector16________Vector32: value\r\n\r\n", @"Invalid request header: 'Header_\x0DVector16________Vector32: value\x0D\x0A'" },
new[] { "Header__Vector16________Vector32\r: value\r\n\r\n", @"Invalid request header: 'Header__Vector16________Vector32\x0D: value\x0D\x0A'" },
new[] { "Header__Vector16________Vector32_\r: value\r\n\r\n", @"Invalid request header: 'Header__Vector16________Vector32_\x0D: value\x0D\x0A'" },
new[] { "Header__Vector16________Vector32Header_\rVector16________Vector32: value\r\n\r\n", @"Invalid request header: 'Header__Vector16________Vector32Header_\x0DVector16________Vector32: value\x0D\x0A'" },
new[] { "Header__Vector16________Vector32Header__Vector16________Vector32\r: value\r\n\r\n", @"Invalid request header: 'Header__Vector16________Vector32Header__Vector16________Vector32\x0D: value\x0D\x0A'" },
new[] { "Header__Vector16________Vector32Header__Vector16________Vector32_\r: value\r\n\r\n", @"Invalid request header: 'Header__Vector16________Vector32Header__Vector16________Vector32_\x0D: value\x0D\x0A'" },
new[] { "Header 1: value1\r\nHeader-2: value2\r\n\r\n", @"Invalid request header: 'Header 1: value1\x0D\x0A'" },
new[] { "Header 1 : value1\r\nHeader-2: value2\r\n\r\n", @"Invalid request header: 'Header 1 : value1\x0D\x0A'" },
new[] { "Header 1\t: value1\r\nHeader-2: value2\r\n\r\n", @"Invalid request header: 'Header 1\x09: value1\x0D\x0A'" },
new[] { "Header 1\r: value1\r\nHeader-2: value2\r\n\r\n", @"Invalid request header: 'Header 1\x0D: value1\x0D\x0A'" },
new[] { "Header-1: value1\r\nHeader 2: value2\r\n\r\n", @"Invalid request header: 'Header 2: value2\x0D\x0A'" },
new[] { "Header-1: value1\r\nHeader-2 : value2\r\n\r\n", @"Invalid request header: 'Header-2 : value2\x0D\x0A'" },
new[] { "Header-1: value1\r\nHeader-2\t: value2\r\n\r\n", @"Invalid request header: 'Header-2\x09: value2\x0D\x0A'" },
new[] { "Header : value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header : value\x0D\x0A") },
new[] { "Header\t: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header\x09: value\x0D\x0A") },
new[] { "Header\r: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header\x0D: value\x0D\x0A") },
new[] { "Header_\rVector16: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header_\x0DVector16: value\x0D\x0A") },
new[] { "Header__Vector16\r: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header__Vector16\x0D: value\x0D\x0A") },
new[] { "Header__Vector16_\r: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header__Vector16_\x0D: value\x0D\x0A") },
new[] { "Header_\rVector16________Vector32: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header_\x0DVector16________Vector32: value\x0D\x0A") },
new[] { "Header__Vector16________Vector32\r: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header__Vector16________Vector32\x0D: value\x0D\x0A") },
new[] { "Header__Vector16________Vector32_\r: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header__Vector16________Vector32_\x0D: value\x0D\x0A") },
new[] { "Header__Vector16________Vector32Header_\rVector16________Vector32: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header__Vector16________Vector32Header_\x0DVector16________Vector32: value\x0D\x0A") },
new[] { "Header__Vector16________Vector32Header__Vector16________Vector32\r: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header__Vector16________Vector32Header__Vector16________Vector32\x0D: value\x0D\x0A") },
new[] { "Header__Vector16________Vector32Header__Vector16________Vector32_\r: value\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header__Vector16________Vector32Header__Vector16________Vector32_\x0D: value\x0D\x0A") },
new[] { "Header 1: value1\r\nHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header 1: value1\x0D\x0A") },
new[] { "Header 1 : value1\r\nHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header 1 : value1\x0D\x0A") },
new[] { "Header 1\t: value1\r\nHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header 1\x09: value1\x0D\x0A") },
new[] { "Header 1\r: value1\r\nHeader-2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header 1\x0D: value1\x0D\x0A") },
new[] { "Header-1: value1\r\nHeader 2: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header 2: value2\x0D\x0A") },
new[] { "Header-1: value1\r\nHeader-2 : value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-2 : value2\x0D\x0A") },
new[] { "Header-1: value1\r\nHeader-2\t: value2\r\n\r\n", CoreStrings.FormatBadRequest_InvalidRequestHeader_Detail(@"Header-2\x09: value2\x0D\x0A") },
// Headers not ending in CRLF line
new[] { "Header-1: value1\r\nHeader-2: value2\r\n\r\r", @"Invalid request headers: missing final CRLF in header fields." },
new[] { "Header-1: value1\r\nHeader-2: value2\r\n\r ", @"Invalid request headers: missing final CRLF in header fields." },
new[] { "Header-1: value1\r\nHeader-2: value2\r\n\r \n", @"Invalid request headers: missing final CRLF in header fields." },
new[] { "Header-1: value1\r\nHeader-2: value2\r\n\r\r", CoreStrings.BadRequest_InvalidRequestHeadersNoCRLF },
new[] { "Header-1: value1\r\nHeader-2: value2\r\n\r ", CoreStrings.BadRequest_InvalidRequestHeadersNoCRLF },
new[] { "Header-1: value1\r\nHeader-2: value2\r\n\r \n", CoreStrings.BadRequest_InvalidRequestHeadersNoCRLF },
};
public static TheoryData<string, string> HostHeaderData