fix some spelling (#2888)
This commit is contained in:
parent
b8e56691cb
commit
d3d7c55198
|
|
@ -22,8 +22,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
// Standard completed task
|
// Standard completed task
|
||||||
private static readonly Func<object, Task> _syncTaskFunc = (obj) => Task.CompletedTask;
|
private static readonly Func<object, Task> _syncTaskFunc = (obj) => Task.CompletedTask;
|
||||||
// Non-standard completed task
|
// Non-standard completed task
|
||||||
private static readonly Task _psuedoAsyncTask = Task.FromResult(27);
|
private static readonly Task _pseudoAsyncTask = Task.FromResult(27);
|
||||||
private static readonly Func<object, Task> _psuedoAsyncTaskFunc = (obj) => _psuedoAsyncTask;
|
private static readonly Func<object, Task> _pseudoAsyncTaskFunc = (obj) => _pseudoAsyncTask;
|
||||||
|
|
||||||
private TestHttp1Connection _http1Connection;
|
private TestHttp1Connection _http1Connection;
|
||||||
private DuplexPipe.DuplexPipePair _pair;
|
private DuplexPipe.DuplexPipePair _pair;
|
||||||
|
|
@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
_http1Connection.OnStarting(_syncTaskFunc, null);
|
_http1Connection.OnStarting(_syncTaskFunc, null);
|
||||||
break;
|
break;
|
||||||
case Startup.Async:
|
case Startup.Async:
|
||||||
_http1Connection.OnStarting(_psuedoAsyncTaskFunc, null);
|
_http1Connection.OnStarting(_pseudoAsyncTaskFunc, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
public void RequestBodyDone(string connectionId, string traceIdentifier) { }
|
public void RequestBodyDone(string connectionId, string traceIdentifier) { }
|
||||||
public void RequestBodyNotEntirelyRead(string connectionId, string traceIdentifier) { }
|
public void RequestBodyNotEntirelyRead(string connectionId, string traceIdentifier) { }
|
||||||
public void RequestBodyDrainTimedOut(string connectionId, string traceIdentifier) { }
|
public void RequestBodyDrainTimedOut(string connectionId, string traceIdentifier) { }
|
||||||
public void RequestBodyMininumDataRateNotSatisfied(string connectionId, string traceIdentifier, double rate) { }
|
public void RequestBodyMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier, double rate) { }
|
||||||
public void ResponseMininumDataRateNotSatisfied(string connectionId, string traceIdentifier) { }
|
public void ResponseMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier) { }
|
||||||
public void ApplicationAbortedConnection(string connectionId, string traceIdentifier) { }
|
public void ApplicationAbortedConnection(string connectionId, string traceIdentifier) { }
|
||||||
public void Http2ConnectionError(string connectionId, Http2ConnectionErrorException ex) { }
|
public void Http2ConnectionError(string connectionId, Http2ConnectionErrorException ex) { }
|
||||||
public void Http2StreamError(string connectionId, Http2StreamErrorException ex) { }
|
public void Http2StreamError(string connectionId, Http2StreamErrorException ex) { }
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
{
|
{
|
||||||
public class PipeThroughputBenchmark
|
public class PipeThroughputBenchmark
|
||||||
{
|
{
|
||||||
private const int _writeLenght = 57;
|
private const int _writeLength = 57;
|
||||||
private const int InnerLoopCount = 512;
|
private const int InnerLoopCount = 512;
|
||||||
|
|
||||||
private Pipe _pipe;
|
private Pipe _pipe;
|
||||||
|
|
@ -32,15 +32,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
{
|
{
|
||||||
for (int i = 0; i < InnerLoopCount; i++)
|
for (int i = 0; i < InnerLoopCount; i++)
|
||||||
{
|
{
|
||||||
_pipe.Writer.GetMemory(_writeLenght);
|
_pipe.Writer.GetMemory(_writeLength);
|
||||||
_pipe.Writer.Advance(_writeLenght);
|
_pipe.Writer.Advance(_writeLength);
|
||||||
await _pipe.Writer.FlushAsync();
|
await _pipe.Writer.FlushAsync();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var reading = Task.Run(async () =>
|
var reading = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
long remaining = InnerLoopCount * _writeLenght;
|
long remaining = InnerLoopCount * _writeLength;
|
||||||
while (remaining != 0)
|
while (remaining != 0)
|
||||||
{
|
{
|
||||||
var result = await _pipe.Reader.ReadAsync();
|
var result = await _pipe.Reader.ReadAsync();
|
||||||
|
|
@ -57,8 +57,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
{
|
{
|
||||||
for (int i = 0; i < InnerLoopCount; i++)
|
for (int i = 0; i < InnerLoopCount; i++)
|
||||||
{
|
{
|
||||||
_pipe.Writer.GetMemory(_writeLenght);
|
_pipe.Writer.GetMemory(_writeLength);
|
||||||
_pipe.Writer.Advance(_writeLenght);
|
_pipe.Writer.Advance(_writeLength);
|
||||||
_pipe.Writer.FlushAsync().GetAwaiter().GetResult();
|
_pipe.Writer.FlushAsync().GetAwaiter().GetResult();
|
||||||
var result = _pipe.Reader.ReadAsync().GetAwaiter().GetResult();
|
var result = _pipe.Reader.ReadAsync().GetAwaiter().GetResult();
|
||||||
_pipe.Reader.AdvanceTo(result.Buffer.End, result.Buffer.End);
|
_pipe.Reader.AdvanceTo(result.Buffer.End, result.Buffer.End);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace System.Buffers
|
||||||
|
|
||||||
private readonly List<Exception> _blockAccessExceptions;
|
private readonly List<Exception> _blockAccessExceptions;
|
||||||
|
|
||||||
private readonly TaskCompletionSource<object> _allBlocksRetuned;
|
private readonly TaskCompletionSource<object> _allBlocksReturned;
|
||||||
|
|
||||||
private int _totalBlocks;
|
private int _totalBlocks;
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace System.Buffers
|
||||||
_rentTracking = rentTracking;
|
_rentTracking = rentTracking;
|
||||||
_blocks = new HashSet<DiagnosticPoolBlock>();
|
_blocks = new HashSet<DiagnosticPoolBlock>();
|
||||||
_syncObj = new object();
|
_syncObj = new object();
|
||||||
_allBlocksRetuned = new TaskCompletionSource<object>();
|
_allBlocksReturned = new TaskCompletionSource<object>();
|
||||||
_blockAccessExceptions = new List<Exception>();
|
_blockAccessExceptions = new List<Exception>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,11 +138,11 @@ namespace System.Buffers
|
||||||
{
|
{
|
||||||
if (_blockAccessExceptions.Any())
|
if (_blockAccessExceptions.Any())
|
||||||
{
|
{
|
||||||
_allBlocksRetuned.SetException(CreateAccessExceptions());
|
_allBlocksReturned.SetException(CreateAccessExceptions());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_allBlocksRetuned.SetResult(null);
|
_allBlocksReturned.SetResult(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,8 +153,8 @@ namespace System.Buffers
|
||||||
|
|
||||||
public async Task WhenAllBlocksReturnedAsync(TimeSpan timeout)
|
public async Task WhenAllBlocksReturnedAsync(TimeSpan timeout)
|
||||||
{
|
{
|
||||||
var task = await Task.WhenAny(_allBlocksRetuned.Task, Task.Delay(timeout));
|
var task = await Task.WhenAny(_allBlocksReturned.Task, Task.Delay(timeout));
|
||||||
if (task != _allBlocksRetuned.Task)
|
if (task != _allBlocksReturned.Task)
|
||||||
{
|
{
|
||||||
MemoryPoolThrowHelper.ThrowInvalidOperationException_BlocksWereNotReturnedInTime(_totalBlocks - _blocks.Count, _totalBlocks, _blocks.ToArray());
|
MemoryPoolThrowHelper.ThrowInvalidOperationException_BlocksWereNotReturnedInTime(_totalBlocks - _blocks.Count, _totalBlocks, _blocks.ToArray());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace System.Buffers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Slab tracking object used by the byte buffer memory pool. A slab is a large allocation which is divided into smaller blocks. The
|
/// Slab tracking object used by the byte buffer memory pool. A slab is a large allocation which is divided into smaller blocks. The
|
||||||
/// individual blocks are then treated as independant array segments.
|
/// individual blocks are then treated as independent array segments.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class MemoryPoolSlab : IDisposable
|
internal class MemoryPoolSlab : IDisposable
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -356,7 +356,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
else if (_requestTargetForm != HttpRequestTarget.OriginForm)
|
else if (_requestTargetForm != HttpRequestTarget.OriginForm)
|
||||||
{
|
{
|
||||||
// Tail call
|
// Tail call
|
||||||
ValidateNonOrginHostHeader(hostText);
|
ValidateNonOriginHostHeader(hostText);
|
||||||
}
|
}
|
||||||
else if (!HttpUtilities.IsHostHeaderValid(hostText))
|
else if (!HttpUtilities.IsHostHeaderValid(hostText))
|
||||||
{
|
{
|
||||||
|
|
@ -364,7 +364,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValidateNonOrginHostHeader(string hostText)
|
private void ValidateNonOriginHostHeader(string hostText)
|
||||||
{
|
{
|
||||||
if (_requestTargetForm == HttpRequestTarget.AuthorityForm)
|
if (_requestTargetForm == HttpRequestTarget.AuthorityForm)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -572,8 +572,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
var extensionCursor = extensionCursorPosition.Value;
|
var extensionCursor = extensionCursorPosition.Value;
|
||||||
var charsToByteCRExclusive = buffer.Slice(0, extensionCursor).Length;
|
var charsToByteCRExclusive = buffer.Slice(0, extensionCursor).Length;
|
||||||
|
|
||||||
var sufixBuffer = buffer.Slice(extensionCursor);
|
var suffixBuffer = buffer.Slice(extensionCursor);
|
||||||
if (sufixBuffer.Length < 2)
|
if (suffixBuffer.Length < 2)
|
||||||
{
|
{
|
||||||
consumed = extensionCursor;
|
consumed = extensionCursor;
|
||||||
examined = buffer.End;
|
examined = buffer.End;
|
||||||
|
|
@ -581,16 +581,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sufixBuffer = sufixBuffer.Slice(0, 2);
|
suffixBuffer = suffixBuffer.Slice(0, 2);
|
||||||
var sufixSpan = sufixBuffer.ToSpan();
|
var sufixSpan = suffixBuffer.ToSpan();
|
||||||
|
|
||||||
if (sufixSpan[1] == '\n')
|
if (sufixSpan[1] == '\n')
|
||||||
{
|
{
|
||||||
// We consumed the \r\n at the end of the extension, so switch modes.
|
// We consumed the \r\n at the end of the extension, so switch modes.
|
||||||
_mode = _inputLength > 0 ? Mode.Data : Mode.Trailer;
|
_mode = _inputLength > 0 ? Mode.Data : Mode.Trailer;
|
||||||
|
|
||||||
consumed = sufixBuffer.End;
|
consumed = suffixBuffer.End;
|
||||||
examined = sufixBuffer.End;
|
examined = suffixBuffer.End;
|
||||||
AddAndCheckConsumedBytes(charsToByteCRExclusive + 2);
|
AddAndCheckConsumedBytes(charsToByteCRExclusive + 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(key))
|
if (string.IsNullOrEmpty(key))
|
||||||
{
|
{
|
||||||
ThrowInvalidEmtpyHeaderName();
|
ThrowInvalidEmptyHeaderName();
|
||||||
}
|
}
|
||||||
if (value.Count == 0)
|
if (value.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(key))
|
if (string.IsNullOrEmpty(key))
|
||||||
{
|
{
|
||||||
ThrowInvalidEmtpyHeaderName();
|
ThrowInvalidEmptyHeaderName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.Count > 0 && !AddValueFast(key, value))
|
if (value.Count > 0 && !AddValueFast(key, value))
|
||||||
|
|
@ -457,7 +457,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
throw new InvalidOperationException(CoreStrings.FormatInvalidAsciiOrControlChar(string.Format("0x{0:X4}", (ushort)ch)));
|
throw new InvalidOperationException(CoreStrings.FormatInvalidAsciiOrControlChar(string.Format("0x{0:X4}", (ushort)ch)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ThrowInvalidEmtpyHeaderName()
|
private static void ThrowInvalidEmptyHeaderName()
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(CoreStrings.InvalidEmptyHeaderName);
|
throw new InvalidOperationException(CoreStrings.InvalidEmptyHeaderName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
const int Shift16Shift24 = (1 << 16) | (1 << 24);
|
const int Shift16Shift24 = (1 << 16) | (1 << 24);
|
||||||
const int Shift8Identity = (1 << 8) | (1);
|
const int Shift8Identity = (1 << 8) | (1);
|
||||||
|
|
||||||
// Encode as bytes upto the first non-ASCII byte and return count encoded
|
// Encode as bytes up to the first non-ASCII byte and return count encoded
|
||||||
int i = 0;
|
int i = 0;
|
||||||
// Use Intrinsic switch
|
// Use Intrinsic switch
|
||||||
if (IntPtr.Size == 8) // 64 bit
|
if (IntPtr.Size == 8) // 64 bit
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
|
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
|
||||||
{
|
{
|
||||||
// Mimics BinaryPrimities with oddly sized units
|
// Mimics BinaryPrimitives with oddly sized units
|
||||||
internal class Bitshifter
|
internal class Bitshifter
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.FlowControl
|
||||||
|
|
||||||
public void Advance(int bytes)
|
public void Advance(int bytes)
|
||||||
{
|
{
|
||||||
var connectionSucess = _connectionLevelFlowControl.TryAdvance(bytes);
|
var connectionSuccess = _connectionLevelFlowControl.TryAdvance(bytes);
|
||||||
|
|
||||||
Debug.Assert(connectionSucess, "Connection-level input flow control should never be aborted.");
|
Debug.Assert(connectionSuccess, "Connection-level input flow control should never be aborted.");
|
||||||
|
|
||||||
if (!_streamLevelFlowControl.TryAdvance(bytes))
|
if (!_streamLevelFlowControl.TryAdvance(bytes))
|
||||||
{
|
{
|
||||||
|
|
@ -78,9 +78,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.FlowControl
|
||||||
|
|
||||||
private void UpdateConnectionWindow(int bytes)
|
private void UpdateConnectionWindow(int bytes)
|
||||||
{
|
{
|
||||||
var connectionSucess = _connectionLevelFlowControl.TryUpdateWindow(bytes, out var connectionWindowUpdateSize);
|
var connectionSuccess = _connectionLevelFlowControl.TryUpdateWindow(bytes, out var connectionWindowUpdateSize);
|
||||||
|
|
||||||
Debug.Assert(connectionSucess, "Connection-level input flow control should never be aborted.");
|
Debug.Assert(connectionSuccess, "Connection-level input flow control should never be aborted.");
|
||||||
|
|
||||||
if (connectionWindowUpdateSize > 0)
|
if (connectionWindowUpdateSize > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.HPack
|
||||||
|
|
||||||
public int Length => GetLength(Name.Length, Value.Length);
|
public int Length => GetLength(Name.Length, Value.Length);
|
||||||
|
|
||||||
public static int GetLength(int nameLength, int valueLenth) => nameLength + valueLenth + 32;
|
public static int GetLength(int nameLength, int valueLength) => nameLength + valueLength + 32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -465,7 +465,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
|
|
||||||
if (rate < minRequestBodyDataRate.BytesPerSecond && !Debugger.IsAttached)
|
if (rate < minRequestBodyDataRate.BytesPerSecond && !Debugger.IsAttached)
|
||||||
{
|
{
|
||||||
Log.RequestBodyMininumDataRateNotSatisfied(_context.ConnectionId, _http1Connection.TraceIdentifier, minRequestBodyDataRate.BytesPerSecond);
|
Log.RequestBodyMinimumDataRateNotSatisfied(_context.ConnectionId, _http1Connection.TraceIdentifier, minRequestBodyDataRate.BytesPerSecond);
|
||||||
RequestTimedOut = true;
|
RequestTimedOut = true;
|
||||||
_http1Connection.SendTimeoutResponse();
|
_http1Connection.SendTimeoutResponse();
|
||||||
}
|
}
|
||||||
|
|
@ -492,7 +492,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
if (_writeTimingWrites > 0 && timestamp > _writeTimingTimeoutTimestamp && !Debugger.IsAttached)
|
if (_writeTimingWrites > 0 && timestamp > _writeTimingTimeoutTimestamp && !Debugger.IsAttached)
|
||||||
{
|
{
|
||||||
RequestTimedOut = true;
|
RequestTimedOut = true;
|
||||||
Log.ResponseMininumDataRateNotSatisfied(_http1Connection.ConnectionIdFeature, _http1Connection.TraceIdentifier);
|
Log.ResponseMinimumDataRateNotSatisfied(_http1Connection.ConnectionIdFeature, _http1Connection.TraceIdentifier);
|
||||||
Abort(new ConnectionAbortedException(CoreStrings.ConnectionTimedBecauseResponseMininumDataRateNotSatisfied));
|
Abort(new ConnectionAbortedException(CoreStrings.ConnectionTimedBecauseResponseMininumDataRateNotSatisfied));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
|
||||||
|
|
||||||
void RequestBodyDrainTimedOut(string connectionId, string traceIdentifier);
|
void RequestBodyDrainTimedOut(string connectionId, string traceIdentifier);
|
||||||
|
|
||||||
void RequestBodyMininumDataRateNotSatisfied(string connectionId, string traceIdentifier, double rate);
|
void RequestBodyMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier, double rate);
|
||||||
|
|
||||||
void ResponseMininumDataRateNotSatisfied(string connectionId, string traceIdentifier);
|
void ResponseMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier);
|
||||||
|
|
||||||
void ApplicationAbortedConnection(string connectionId, string traceIdentifier);
|
void ApplicationAbortedConnection(string connectionId, string traceIdentifier);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
LoggerMessage.Define<string, string>(LogLevel.Debug, new EventId(26, nameof(RequestBodyDone)), @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": done reading request body.");
|
LoggerMessage.Define<string, string>(LogLevel.Debug, new EventId(26, nameof(RequestBodyDone)), @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": done reading request body.");
|
||||||
|
|
||||||
private static readonly Action<ILogger, string, string, double, Exception> _requestBodyMinimumDataRateNotSatisfied =
|
private static readonly Action<ILogger, string, string, double, Exception> _requestBodyMinimumDataRateNotSatisfied =
|
||||||
LoggerMessage.Define<string, string, double>(LogLevel.Information, new EventId(27, nameof(RequestBodyMininumDataRateNotSatisfied)), @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": the request timed out because it was not sent by the client at a minimum of {Rate} bytes/second.");
|
LoggerMessage.Define<string, string, double>(LogLevel.Information, new EventId(27, nameof(RequestBodyMinimumDataRateNotSatisfied)), @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": the request timed out because it was not sent by the client at a minimum of {Rate} bytes/second.");
|
||||||
|
|
||||||
private static readonly Action<ILogger, string, string, Exception> _responseMinimumDataRateNotSatisfied =
|
private static readonly Action<ILogger, string, string, Exception> _responseMinimumDataRateNotSatisfied =
|
||||||
LoggerMessage.Define<string, string>(LogLevel.Information, new EventId(28, nameof(ResponseMininumDataRateNotSatisfied)), @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": the connection was closed because the response was not read by the client at the specified minimum data rate.");
|
LoggerMessage.Define<string, string>(LogLevel.Information, new EventId(28, nameof(ResponseMinimumDataRateNotSatisfied)), @"Connection id ""{ConnectionId}"", Request id ""{TraceIdentifier}"": the connection was closed because the response was not read by the client at the specified minimum data rate.");
|
||||||
|
|
||||||
private static readonly Action<ILogger, string, Exception> _http2ConnectionError =
|
private static readonly Action<ILogger, string, Exception> _http2ConnectionError =
|
||||||
LoggerMessage.Define<string>(LogLevel.Information, new EventId(29, nameof(Http2ConnectionError)), @"Connection id ""{ConnectionId}"": HTTP/2 connection error.");
|
LoggerMessage.Define<string>(LogLevel.Information, new EventId(29, nameof(Http2ConnectionError)), @"Connection id ""{ConnectionId}"": HTTP/2 connection error.");
|
||||||
|
|
@ -199,7 +199,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
_requestBodyDone(_logger, connectionId, traceIdentifier, null);
|
_requestBodyDone(_logger, connectionId, traceIdentifier, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void RequestBodyMininumDataRateNotSatisfied(string connectionId, string traceIdentifier, double rate)
|
public virtual void RequestBodyMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier, double rate)
|
||||||
{
|
{
|
||||||
_requestBodyMinimumDataRateNotSatisfied(_logger, connectionId, traceIdentifier, rate, null);
|
_requestBodyMinimumDataRateNotSatisfied(_logger, connectionId, traceIdentifier, rate, null);
|
||||||
}
|
}
|
||||||
|
|
@ -214,7 +214,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
_requestBodyDrainTimedOut(_logger, connectionId, traceIdentifier, null);
|
_requestBodyDrainTimedOut(_logger, connectionId, traceIdentifier, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ResponseMininumDataRateNotSatisfied(string connectionId, string traceIdentifier)
|
public virtual void ResponseMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier)
|
||||||
{
|
{
|
||||||
_responseMinimumDataRateNotSatisfied(_logger, connectionId, traceIdentifier, null);
|
_responseMinimumDataRateNotSatisfied(_logger, connectionId, traceIdentifier, null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
||||||
(handle, status, state) => ReadCallback(handle, status, state);
|
(handle, status, state) => ReadCallback(handle, status, state);
|
||||||
|
|
||||||
private static readonly Func<UvStreamHandle, int, object, LibuvFunctions.uv_buf_t> _allocCallback =
|
private static readonly Func<UvStreamHandle, int, object, LibuvFunctions.uv_buf_t> _allocCallback =
|
||||||
(handle, suggestedsize, state) => AllocCallback(handle, suggestedsize, state);
|
(handle, suggestedSize, state) => AllocCallback(handle, suggestedSize, state);
|
||||||
|
|
||||||
private readonly UvStreamHandle _socket;
|
private readonly UvStreamHandle _socket;
|
||||||
private readonly CancellationTokenSource _connectionClosedTokenSource = new CancellationTokenSource();
|
private readonly CancellationTokenSource _connectionClosedTokenSource = new CancellationTokenSource();
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
||||||
protected virtual void DispatchConnection(UvStreamHandle socket)
|
protected virtual void DispatchConnection(UvStreamHandle socket)
|
||||||
{
|
{
|
||||||
// REVIEW: This task should be tracked by the server for graceful shutdown
|
// REVIEW: This task should be tracked by the server for graceful shutdown
|
||||||
// Today it's handled specifically for http but not for aribitrary middleware
|
// Today it's handled specifically for http but not for arbitrary middleware
|
||||||
_ = HandleConnectionAsync(socket);
|
_ = HandleConnectionAsync(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
||||||
DispatchPipe.Accept(acceptSocket);
|
DispatchPipe.Accept(acceptSocket);
|
||||||
|
|
||||||
// REVIEW: This task should be tracked by the server for graceful shutdown
|
// REVIEW: This task should be tracked by the server for graceful shutdown
|
||||||
// Today it's handled specifically for http but not for aribitrary middleware
|
// Today it's handled specifically for http but not for arbitrary middleware
|
||||||
_ = HandleConnectionAsync(acceptSocket);
|
_ = HandleConnectionAsync(acceptSocket);
|
||||||
}
|
}
|
||||||
catch (UvException ex) when (LibuvConstants.IsConnectionReset(ex.StatusCode))
|
catch (UvException ex) when (LibuvConstants.IsConnectionReset(ex.StatusCode))
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
|
||||||
int family = (int)_field0;
|
int family = (int)_field0;
|
||||||
if (PlatformApis.IsDarwin)
|
if (PlatformApis.IsDarwin)
|
||||||
{
|
{
|
||||||
// see explaination in example 4
|
// see explanation in example 4
|
||||||
family = family >> 8;
|
family = family >> 8;
|
||||||
}
|
}
|
||||||
family = family & 0xFF;
|
family = family & 0xFF;
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
_httpConnection.Debugger = mockDebugger.Object;
|
_httpConnection.Debugger = mockDebugger.Object;
|
||||||
var bytesPerSecond = 100;
|
var bytesPerSecond = 100;
|
||||||
var mockLogger = new Mock<IKestrelTrace>();
|
var mockLogger = new Mock<IKestrelTrace>();
|
||||||
mockLogger.Setup(l => l.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>())).Throws(new InvalidOperationException("Should not log"));
|
mockLogger.Setup(l => l.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>())).Throws(new InvalidOperationException("Should not log"));
|
||||||
|
|
||||||
TickBodyWithMinimumDataRate(mockLogger.Object, bytesPerSecond);
|
TickBodyWithMinimumDataRate(mockLogger.Object, bytesPerSecond);
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Timed out
|
// Timed out
|
||||||
Assert.True(_httpConnection.RequestTimedOut);
|
Assert.True(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(logger =>
|
mockLogger.Verify(logger =>
|
||||||
logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Once);
|
logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TickBodyWithMinimumDataRate(IKestrelTrace logger, int bytesPerSecond)
|
private void TickBodyWithMinimumDataRate(IKestrelTrace logger, int bytesPerSecond)
|
||||||
|
|
@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Not timed out
|
// Not timed out
|
||||||
Assert.False(_httpConnection.RequestTimedOut);
|
Assert.False(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(logger =>
|
mockLogger.Verify(logger =>
|
||||||
logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
||||||
|
|
||||||
// Tick after grace period w/ low data rate
|
// Tick after grace period w/ low data rate
|
||||||
now += TimeSpan.FromSeconds(2);
|
now += TimeSpan.FromSeconds(2);
|
||||||
|
|
@ -165,7 +165,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Timed out
|
// Timed out
|
||||||
Assert.True(_httpConnection.RequestTimedOut);
|
Assert.True(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(logger =>
|
mockLogger.Verify(logger =>
|
||||||
logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Once);
|
logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -202,7 +202,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Not timed out
|
// Not timed out
|
||||||
Assert.False(_httpConnection.RequestTimedOut);
|
Assert.False(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(logger =>
|
mockLogger.Verify(logger =>
|
||||||
logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
||||||
|
|
||||||
// Data rate: 150 bytes/second
|
// Data rate: 150 bytes/second
|
||||||
now += TimeSpan.FromSeconds(1);
|
now += TimeSpan.FromSeconds(1);
|
||||||
|
|
@ -212,7 +212,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Not timed out
|
// Not timed out
|
||||||
Assert.False(_httpConnection.RequestTimedOut);
|
Assert.False(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(logger =>
|
mockLogger.Verify(logger =>
|
||||||
logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
||||||
|
|
||||||
// Data rate: 120 bytes/second
|
// Data rate: 120 bytes/second
|
||||||
now += TimeSpan.FromSeconds(1);
|
now += TimeSpan.FromSeconds(1);
|
||||||
|
|
@ -222,7 +222,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Not timed out
|
// Not timed out
|
||||||
Assert.False(_httpConnection.RequestTimedOut);
|
Assert.False(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(logger =>
|
mockLogger.Verify(logger =>
|
||||||
logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
||||||
|
|
||||||
// Data rate: 100 bytes/second
|
// Data rate: 100 bytes/second
|
||||||
now += TimeSpan.FromSeconds(1);
|
now += TimeSpan.FromSeconds(1);
|
||||||
|
|
@ -232,7 +232,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Not timed out
|
// Not timed out
|
||||||
Assert.False(_httpConnection.RequestTimedOut);
|
Assert.False(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(logger =>
|
mockLogger.Verify(logger =>
|
||||||
logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Never);
|
||||||
|
|
||||||
// Data rate: ~85 bytes/second
|
// Data rate: ~85 bytes/second
|
||||||
now += TimeSpan.FromSeconds(1);
|
now += TimeSpan.FromSeconds(1);
|
||||||
|
|
@ -242,7 +242,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Timed out
|
// Timed out
|
||||||
Assert.True(_httpConnection.RequestTimedOut);
|
Assert.True(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(logger =>
|
mockLogger.Verify(logger =>
|
||||||
logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Once);
|
logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), bytesPerSecond), Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -285,7 +285,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Not timed out
|
// Not timed out
|
||||||
Assert.False(_httpConnection.RequestTimedOut);
|
Assert.False(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(
|
mockLogger.Verify(
|
||||||
logger => logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
logger => logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
||||||
Times.Never);
|
Times.Never);
|
||||||
|
|
||||||
// Resume at 6.5s
|
// Resume at 6.5s
|
||||||
|
|
@ -299,7 +299,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Not timed out
|
// Not timed out
|
||||||
Assert.False(_httpConnection.RequestTimedOut);
|
Assert.False(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(
|
mockLogger.Verify(
|
||||||
logger => logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
logger => logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
||||||
Times.Never);
|
Times.Never);
|
||||||
|
|
||||||
// Tick at 10s, expected counted time is 7s, expected data rate drops below 100 bytes/second
|
// Tick at 10s, expected counted time is 7s, expected data rate drops below 100 bytes/second
|
||||||
|
|
@ -309,7 +309,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Timed out
|
// Timed out
|
||||||
Assert.True(_httpConnection.RequestTimedOut);
|
Assert.True(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(
|
mockLogger.Verify(
|
||||||
logger => logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
logger => logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
||||||
Times.Once);
|
Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -341,7 +341,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Not timed out
|
// Not timed out
|
||||||
Assert.False(_httpConnection.RequestTimedOut);
|
Assert.False(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(
|
mockLogger.Verify(
|
||||||
logger => logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
logger => logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
||||||
Times.Never);
|
Times.Never);
|
||||||
|
|
||||||
// Pause at 2.25s
|
// Pause at 2.25s
|
||||||
|
|
@ -360,7 +360,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Not timed out
|
// Not timed out
|
||||||
Assert.False(_httpConnection.RequestTimedOut);
|
Assert.False(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(
|
mockLogger.Verify(
|
||||||
logger => logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
logger => logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
||||||
Times.Never);
|
Times.Never);
|
||||||
|
|
||||||
// Tick at 4s, expected counted time is 4s, expected data rate drops below 100 bytes/second
|
// Tick at 4s, expected counted time is 4s, expected data rate drops below 100 bytes/second
|
||||||
|
|
@ -370,7 +370,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
// Timed out
|
// Timed out
|
||||||
Assert.True(_httpConnection.RequestTimedOut);
|
Assert.True(_httpConnection.RequestTimedOut);
|
||||||
mockLogger.Verify(
|
mockLogger.Verify(
|
||||||
logger => logger.RequestBodyMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
logger => logger.RequestBodyMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<double>()),
|
||||||
Times.Once);
|
Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -539,7 +539,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task WriteTimingAbortsConnectionWhenRepeadtedSmallWritesDoNotCompleteWithMinimumDataRate()
|
public async Task WriteTimingAbortsConnectionWhenRepeatedSmallWritesDoNotCompleteWithMinimumDataRate()
|
||||||
{
|
{
|
||||||
var systemClock = new MockSystemClock();
|
var systemClock = new MockSystemClock();
|
||||||
var minResponseDataRate = new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(5));
|
var minResponseDataRate = new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(5));
|
||||||
|
|
|
||||||
|
|
@ -494,7 +494,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doesn't put empty blocks inbetween every byte
|
// Doesn't put empty blocks in between every byte
|
||||||
internal class BytePerSegmentTestSequenceFactory : ReadOnlySequenceFactory
|
internal class BytePerSegmentTestSequenceFactory : ReadOnlySequenceFactory
|
||||||
{
|
{
|
||||||
public static ReadOnlySequenceFactory Instance { get; } = new HttpParserTests.BytePerSegmentTestSequenceFactory();
|
public static ReadOnlySequenceFactory Instance { get; } = new HttpParserTests.BytePerSegmentTestSequenceFactory();
|
||||||
|
|
|
||||||
|
|
@ -562,7 +562,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
|
|
||||||
await body.StopAsync();
|
await body.StopAsync();
|
||||||
|
|
||||||
// Add some more data. Checking for cancelation and exiting the loop
|
// Add some more data. Checking for cancellation and exiting the loop
|
||||||
// should take priority over reading this data.
|
// should take priority over reading this data.
|
||||||
input.Add("b");
|
input.Add("b");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
|
||||||
public class ConfigurationReaderTests
|
public class ConfigurationReaderTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ReadCertificatesWhenNoCertificatsSection_ReturnsEmptyCollection()
|
public void ReadCertificatesWhenNoCertificatesSection_ReturnsEmptyCollection()
|
||||||
{
|
{
|
||||||
var config = new ConfigurationBuilder().AddInMemoryCollection().Build();
|
var config = new ConfigurationBuilder().AddInMemoryCollection().Build();
|
||||||
var reader = new ConfigurationReader(config);
|
var reader = new ConfigurationReader(config);
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
RunTestWithStaticPort(port => RegisterAddresses_Success($"{addressInput}:{port}", testUrls, port));
|
RunTestWithStaticPort(port => RegisterAddresses_Success($"{addressInput}:{port}", testUrls, port));
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task RegisterHttpAddress_UpradedToHttpsByConfigureEndpointDefaults()
|
public async Task RegisterHttpAddress_UpgradedToHttpsByConfigureEndpointDefaults()
|
||||||
{
|
{
|
||||||
var hostBuilder = TransportSelector.GetWebHostBuilder()
|
var hostBuilder = TransportSelector.GetWebHostBuilder()
|
||||||
.UseKestrel(serverOptions =>
|
.UseKestrel(serverOptions =>
|
||||||
|
|
@ -676,14 +676,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("ftp://localhost")]
|
[InlineData("ftp://localhost")]
|
||||||
[InlineData("ssh://localhost")]
|
[InlineData("ssh://localhost")]
|
||||||
public void ThrowsForUnsupportedAddressFromHosting(string addr)
|
public void ThrowsForUnsupportedAddressFromHosting(string address)
|
||||||
{
|
{
|
||||||
TestApplicationErrorLogger.IgnoredExceptions.Add(typeof(InvalidOperationException));
|
TestApplicationErrorLogger.IgnoredExceptions.Add(typeof(InvalidOperationException));
|
||||||
|
|
||||||
var hostBuilder = TransportSelector.GetWebHostBuilder()
|
var hostBuilder = TransportSelector.GetWebHostBuilder()
|
||||||
.ConfigureServices(AddTestLogging)
|
.ConfigureServices(AddTestLogging)
|
||||||
.UseKestrel()
|
.UseKestrel()
|
||||||
.UseUrls(addr)
|
.UseUrls(address)
|
||||||
.Configure(ConfigureEchoAddress);
|
.Configure(ConfigureEchoAddress);
|
||||||
|
|
||||||
using (var host = hostBuilder.Build())
|
using (var host = hostBuilder.Build())
|
||||||
|
|
@ -786,7 +786,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
|
|
||||||
using (var socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
|
using (var socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
|
||||||
{
|
{
|
||||||
// Bind first to IPv6Any to ensure both the IPv4 and IPv6 ports are avaiable.
|
// Bind first to IPv6Any to ensure both the IPv4 and IPv6 ports are available.
|
||||||
socket.Bind(new IPEndPoint(IPAddress.IPv6Any, 0));
|
socket.Bind(new IPEndPoint(IPAddress.IPv6Any, 0));
|
||||||
socket.Listen(0);
|
socket.Listen(0);
|
||||||
port = ((IPEndPoint)socket.LocalEndPoint).Port;
|
port = ((IPEndPoint)socket.LocalEndPoint).Port;
|
||||||
|
|
|
||||||
|
|
@ -470,7 +470,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
|
|
||||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||||
mockKestrelTrace
|
mockKestrelTrace
|
||||||
.Setup(trace => trace.ResponseMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()))
|
.Setup(trace => trace.ResponseMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()))
|
||||||
.Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
|
.Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
|
||||||
mockKestrelTrace
|
mockKestrelTrace
|
||||||
.Setup(trace => trace.ConnectionStop(It.IsAny<string>()))
|
.Setup(trace => trace.ConnectionStop(It.IsAny<string>()))
|
||||||
|
|
@ -560,7 +560,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
|
|
||||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||||
mockKestrelTrace
|
mockKestrelTrace
|
||||||
.Setup(trace => trace.ResponseMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()))
|
.Setup(trace => trace.ResponseMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()))
|
||||||
.Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
|
.Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
|
||||||
mockKestrelTrace
|
mockKestrelTrace
|
||||||
.Setup(trace => trace.ConnectionStop(It.IsAny<string>()))
|
.Setup(trace => trace.ConnectionStop(It.IsAny<string>()))
|
||||||
|
|
@ -645,7 +645,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
|
|
||||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||||
mockKestrelTrace
|
mockKestrelTrace
|
||||||
.Setup(trace => trace.ResponseMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()))
|
.Setup(trace => trace.ResponseMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()))
|
||||||
.Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
|
.Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
|
||||||
mockKestrelTrace
|
mockKestrelTrace
|
||||||
.Setup(trace => trace.ConnectionStop(It.IsAny<string>()))
|
.Setup(trace => trace.ConnectionStop(It.IsAny<string>()))
|
||||||
|
|
@ -779,7 +779,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
await AssertStreamCompleted(connection.Stream, minTotalOutputSize, targetBytesPerSecond);
|
await AssertStreamCompleted(connection.Stream, minTotalOutputSize, targetBytesPerSecond);
|
||||||
await appFuncCompleted.Task.DefaultTimeout();
|
await appFuncCompleted.Task.DefaultTimeout();
|
||||||
|
|
||||||
mockKestrelTrace.Verify(t => t.ResponseMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
mockKestrelTrace.Verify(t => t.ResponseMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
||||||
mockKestrelTrace.Verify(t => t.ConnectionStop(It.IsAny<string>()), Times.Once());
|
mockKestrelTrace.Verify(t => t.ConnectionStop(It.IsAny<string>()), Times.Once());
|
||||||
Assert.False(requestAborted);
|
Assert.False(requestAborted);
|
||||||
}
|
}
|
||||||
|
|
@ -854,7 +854,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
var targetBytesPerSecond = responseSize / 4;
|
var targetBytesPerSecond = responseSize / 4;
|
||||||
await AssertStreamCompleted(connection.Stream, minTotalOutputSize, targetBytesPerSecond);
|
await AssertStreamCompleted(connection.Stream, minTotalOutputSize, targetBytesPerSecond);
|
||||||
|
|
||||||
mockKestrelTrace.Verify(t => t.ResponseMininumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
mockKestrelTrace.Verify(t => t.ResponseMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
||||||
mockKestrelTrace.Verify(t => t.ConnectionStop(It.IsAny<string>()), Times.Once());
|
mockKestrelTrace.Verify(t => t.ConnectionStop(It.IsAny<string>()), Times.Once());
|
||||||
Assert.False(requestAborted);
|
Assert.False(requestAborted);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,16 +153,16 @@ namespace Microsoft.AspNetCore.Testing
|
||||||
_trace2.RequestBodyDrainTimedOut(connectionId, traceIdentifier);
|
_trace2.RequestBodyDrainTimedOut(connectionId, traceIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestBodyMininumDataRateNotSatisfied(string connectionId, string traceIdentifier, double rate)
|
public void RequestBodyMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier, double rate)
|
||||||
{
|
{
|
||||||
_trace1.RequestBodyMininumDataRateNotSatisfied(connectionId, traceIdentifier, rate);
|
_trace1.RequestBodyMinimumDataRateNotSatisfied(connectionId, traceIdentifier, rate);
|
||||||
_trace2.RequestBodyMininumDataRateNotSatisfied(connectionId, traceIdentifier, rate);
|
_trace2.RequestBodyMinimumDataRateNotSatisfied(connectionId, traceIdentifier, rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResponseMininumDataRateNotSatisfied(string connectionId, string traceIdentifier)
|
public void ResponseMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier)
|
||||||
{
|
{
|
||||||
_trace1.ResponseMininumDataRateNotSatisfied(connectionId, traceIdentifier);
|
_trace1.ResponseMinimumDataRateNotSatisfied(connectionId, traceIdentifier);
|
||||||
_trace2.ResponseMininumDataRateNotSatisfied(connectionId, traceIdentifier);
|
_trace2.ResponseMinimumDataRateNotSatisfied(connectionId, traceIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplicationAbortedConnection(string connectionId, string traceIdentifier)
|
public void ApplicationAbortedConnection(string connectionId, string traceIdentifier)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
return NetworkInterface.GetAllNetworkInterfaces()
|
return NetworkInterface.GetAllNetworkInterfaces()
|
||||||
.Where(iface => iface.OperationalStatus == OperationalStatus.Up)
|
.Where(iface => iface.OperationalStatus == OperationalStatus.Up)
|
||||||
.SelectMany(iface => iface.GetIPProperties().UnicastAddresses)
|
.SelectMany(iface => iface.GetIPProperties().UnicastAddresses)
|
||||||
.Any(addrInfo => addrInfo.Address.AddressFamily == AddressFamily.InterNetworkV6 && addrInfo.Address.ScopeId != 0);
|
.Any(addressInfo => addressInfo.Address.AddressFamily == AddressFamily.InterNetworkV6 && addressInfo.Address.ScopeId != 0);
|
||||||
}
|
}
|
||||||
catch (SocketException)
|
catch (SocketException)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ namespace CodeGenerator
|
||||||
PrimaryHeader = responsePrimaryHeaders.Contains("Content-Length")
|
PrimaryHeader = responsePrimaryHeaders.Contains("Content-Length")
|
||||||
}})
|
}})
|
||||||
.ToArray();
|
.ToArray();
|
||||||
// 63 for reponseHeaders as it steals one bit for Content-Length in CopyTo(ref MemoryPoolIterator output)
|
// 63 for responseHeaders as it steals one bit for Content-Length in CopyTo(ref MemoryPoolIterator output)
|
||||||
Debug.Assert(responseHeaders.Length <= 63);
|
Debug.Assert(responseHeaders.Length <= 63);
|
||||||
Debug.Assert(responseHeaders.Max(x => x.Index) <= 62);
|
Debug.Assert(responseHeaders.Max(x => x.Index) <= 62);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue