Merge branch 'release/2.2'
This commit is contained in:
commit
6183f1851e
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Microsoft.AspNetCore;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace PlatformBenchmarks
|
namespace PlatformBenchmarks
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Buffers.Text;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
|
||||||
namespace PlatformBenchmarks
|
namespace PlatformBenchmarks
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Buffers;
|
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Connections;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Buffers;
|
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,8 @@ namespace LargeResponseApp
|
||||||
{
|
{
|
||||||
app.Run(async (context) =>
|
app.Run(async (context) =>
|
||||||
{
|
{
|
||||||
int numChunks;
|
|
||||||
var path = context.Request.Path;
|
var path = context.Request.Path;
|
||||||
if (!path.HasValue || !int.TryParse(path.Value.Substring(1), out numChunks))
|
if (!path.HasValue || !int.TryParse(path.Value.Substring(1), out var numChunks))
|
||||||
{
|
{
|
||||||
numChunks = _defaultNumChunks;
|
numChunks = _defaultNumChunks;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Https.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Https.Internal;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Connections
|
namespace Microsoft.AspNetCore.Connections
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Connections
|
namespace Microsoft.AspNetCore.Connections
|
||||||
|
|
@ -98,8 +96,7 @@ namespace Microsoft.AspNetCore.Connections
|
||||||
|
|
||||||
bool ICollection<KeyValuePair<object, object>>.Remove(KeyValuePair<object, object> item)
|
bool ICollection<KeyValuePair<object, object>>.Remove(KeyValuePair<object, object> item)
|
||||||
{
|
{
|
||||||
object value;
|
if (Items.TryGetValue(item.Key, out var value) && Equals(item.Value, value))
|
||||||
if (Items.TryGetValue(item.Key, out value) && Equals(item.Value, value))
|
|
||||||
{
|
{
|
||||||
return Items.Remove(item.Key);
|
return Items.Remove(item.Key);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// 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;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Connections.Features
|
namespace Microsoft.AspNetCore.Connections.Features
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// 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.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Connections.Features
|
namespace Microsoft.AspNetCore.Connections.Features
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Buffers;
|
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Connections.Features
|
namespace Microsoft.AspNetCore.Connections.Features
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.IO.Pipelines;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Connections.Features
|
namespace Microsoft.AspNetCore.Connections.Features
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// A callback that will be invoked to dynamically select a server certificate. This is higher priority than ServerCertificate.
|
/// A callback that will be invoked to dynamically select a server certificate. This is higher priority than ServerCertificate.
|
||||||
/// If SNI is not avialable then the name parameter will be null.
|
/// If SNI is not available then the name parameter will be null.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// If the server certificate has an Extended Key Usage extension, the usages must include Server Authentication (OID 1.3.6.1.5.5.7.3.1).
|
/// If the server certificate has an Extended Key Usage extension, the usages must include Server Authentication (OID 1.3.6.1.5.5.7.3.1).
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
// Copyright (c) Microsoft. All rights reserved.
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Buffers;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace System.Buffers
|
namespace System.Buffers
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
private void ReadEndpointDefaults()
|
private void ReadEndpointDefaults()
|
||||||
{
|
{
|
||||||
var configSection = _configuration.GetSection(EndpointDefaultsKey);
|
var configSection = _configuration.GetSection(EndpointDefaultsKey);
|
||||||
_endpointDefaults = new EndpointDefaults()
|
_endpointDefaults = new EndpointDefaults
|
||||||
{
|
{
|
||||||
Protocols = ParseProtocols(configSection[ProtocolsKey])
|
Protocols = ParseProtocols(configSection[ProtocolsKey])
|
||||||
};
|
};
|
||||||
|
|
@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
throw new InvalidOperationException(CoreStrings.FormatEndpointMissingUrl(endpointConfig.Key));
|
throw new InvalidOperationException(CoreStrings.FormatEndpointMissingUrl(endpointConfig.Key));
|
||||||
}
|
}
|
||||||
|
|
||||||
var endpoint = new EndpointConfig()
|
var endpoint = new EndpointConfig
|
||||||
{
|
{
|
||||||
Name = endpointConfig.Key,
|
Name = endpointConfig.Key,
|
||||||
Url = url,
|
Url = url,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using System.Buffers;
|
namespace System.IO.Pipelines
|
||||||
|
|
||||||
namespace System.IO.Pipelines
|
|
||||||
{
|
{
|
||||||
internal class DuplexPipe : IDuplexPipe
|
internal class DuplexPipe : IDuplexPipe
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
Buffer.BlockCopy(_datePreambleBytes, 0, dateBytes, 0, _datePreambleBytes.Length);
|
Buffer.BlockCopy(_datePreambleBytes, 0, dateBytes, 0, _datePreambleBytes.Length);
|
||||||
Encoding.ASCII.GetBytes(dateValue, 0, dateValue.Length, dateBytes, _datePreambleBytes.Length);
|
Encoding.ASCII.GetBytes(dateValue, 0, dateValue.Length, dateBytes, _datePreambleBytes.Length);
|
||||||
|
|
||||||
var dateValues = new DateHeaderValues()
|
var dateValues = new DateHeaderValues
|
||||||
{
|
{
|
||||||
Bytes = dateBytes,
|
Bytes = dateBytes,
|
||||||
String = dateValue
|
String = dateValue
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
// TryRead can throw OperationCanceledException https://github.com/dotnet/corefx/issues/32029
|
// TryRead can throw OperationCanceledException https://github.com/dotnet/corefx/issues/32029
|
||||||
// beacuse of buggy logic, this works around that for now
|
// because of buggy logic, this works around that for now
|
||||||
}
|
}
|
||||||
catch (BadHttpRequestException ex)
|
catch (BadHttpRequestException ex)
|
||||||
{
|
{
|
||||||
|
|
@ -596,9 +596,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
}
|
}
|
||||||
|
|
||||||
suffixBuffer = suffixBuffer.Slice(0, 2);
|
suffixBuffer = suffixBuffer.Slice(0, 2);
|
||||||
var sufixSpan = suffixBuffer.ToSpan();
|
var suffixSpan = suffixBuffer.ToSpan();
|
||||||
|
|
||||||
if (sufixSpan[1] == '\n')
|
if (suffixSpan[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;
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
StringValues value;
|
TryGetValueFast(key, out var value);
|
||||||
TryGetValueFast(key, out value);
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
|
|
@ -66,8 +65,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// Unlike the IHeaderDictionary version, this getter will throw a KeyNotFoundException.
|
// Unlike the IHeaderDictionary version, this getter will throw a KeyNotFoundException.
|
||||||
StringValues value;
|
if (!TryGetValueFast(key, out var value))
|
||||||
if (!TryGetValueFast(key, out value))
|
|
||||||
{
|
{
|
||||||
ThrowKeyNotFoundException();
|
ThrowKeyNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
@ -197,9 +195,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
|
|
||||||
bool ICollection<KeyValuePair<string, StringValues>>.Contains(KeyValuePair<string, StringValues> item)
|
bool ICollection<KeyValuePair<string, StringValues>>.Contains(KeyValuePair<string, StringValues> item)
|
||||||
{
|
{
|
||||||
StringValues value;
|
|
||||||
return
|
return
|
||||||
TryGetValueFast(item.Key, out value) &&
|
TryGetValueFast(item.Key, out var value) &&
|
||||||
value.Equals(item.Value);
|
value.Equals(item.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,9 +226,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
|
|
||||||
bool ICollection<KeyValuePair<string, StringValues>>.Remove(KeyValuePair<string, StringValues> item)
|
bool ICollection<KeyValuePair<string, StringValues>>.Remove(KeyValuePair<string, StringValues> item)
|
||||||
{
|
{
|
||||||
StringValues value;
|
|
||||||
return
|
return
|
||||||
TryGetValueFast(item.Key, out value) &&
|
TryGetValueFast(item.Key, out var value) &&
|
||||||
value.Equals(item.Value) &&
|
value.Equals(item.Value) &&
|
||||||
RemoveFast(item.Key);
|
RemoveFast(item.Key);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
|
|
@ -73,9 +72,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
|
|
||||||
private unsafe void ParseRequestLine(TRequestHandler handler, byte* data, int length)
|
private unsafe void ParseRequestLine(TRequestHandler handler, byte* data, int length)
|
||||||
{
|
{
|
||||||
int offset;
|
|
||||||
// Get Method and set the offset
|
// Get Method and set the offset
|
||||||
var method = HttpUtilities.GetKnownMethod(data, length, out offset);
|
var method = HttpUtilities.GetKnownMethod(data, length, out var offset);
|
||||||
|
|
||||||
Span<byte> customMethod = method == HttpMethod.Custom ?
|
Span<byte> customMethod = method == HttpMethod.Custom ?
|
||||||
GetUnknownMethod(data, length, out offset) :
|
GetUnknownMethod(data, length, out offset) :
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
|
|
@ -16,8 +15,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
{
|
{
|
||||||
private static long ParseContentLength(string value)
|
private static long ParseContentLength(string value)
|
||||||
{
|
{
|
||||||
long parsed;
|
if (!HeaderUtilities.TryParseNonNegativeInt64(value, out var parsed))
|
||||||
if (!HeaderUtilities.TryParseNonNegativeInt64(value, out parsed))
|
|
||||||
{
|
{
|
||||||
BadHttpRequestException.Throw(RequestRejectionReason.InvalidContentLength, value);
|
BadHttpRequestException.Throw(RequestRejectionReason.InvalidContentLength, value);
|
||||||
}
|
}
|
||||||
|
|
@ -51,8 +49,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringValues existing;
|
Unknown.TryGetValue(key, out var existing);
|
||||||
Unknown.TryGetValue(key, out existing);
|
|
||||||
Unknown[key] = AppendValue(existing, value);
|
Unknown[key] = AppendValue(existing, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
|
||||||
|
|
||||||
private static long ParseContentLength(string value)
|
private static long ParseContentLength(string value)
|
||||||
{
|
{
|
||||||
long parsed;
|
if (!HeaderUtilities.TryParseNonNegativeInt64(value, out var parsed))
|
||||||
if (!HeaderUtilities.TryParseNonNegativeInt64(value, out parsed))
|
|
||||||
{
|
{
|
||||||
ThrowInvalidContentLengthException(value);
|
ThrowInvalidContentLengthException(value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNetCore.Connections.Abstractions;
|
using Microsoft.AspNetCore.Connections.Abstractions;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||||
|
|
|
||||||
|
|
@ -977,7 +977,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
|
||||||
// https://github.com/aspnet/KestrelHttpServer/issues/2051
|
// https://github.com/aspnet/KestrelHttpServer/issues/2051
|
||||||
if (_requestHeaderParsingState != RequestHeaderParsingState.Trailers)
|
if (_requestHeaderParsingState != RequestHeaderParsingState.Trailers)
|
||||||
{
|
{
|
||||||
// Throws BadReqeust for header count limit breaches.
|
// Throws BadRequest for header count limit breaches.
|
||||||
// Throws InvalidOperation for bad encoding.
|
// Throws InvalidOperation for bad encoding.
|
||||||
_currentHeadersStream.OnHeader(name, value);
|
_currentHeadersStream.OnHeader(name, value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
|
|
||||||
using (connectionLifetimeNotificationFeature?.ConnectionClosedRequested.Register(state => ((HttpConnection)state).StopProcessingNextRequest(), this))
|
using (connectionLifetimeNotificationFeature?.ConnectionClosedRequested.Register(state => ((HttpConnection)state).StopProcessingNextRequest(), this))
|
||||||
{
|
{
|
||||||
// Ensure TimeoutControl._lastTimestamp is intialized before anything that could set timeouts runs.
|
// Ensure TimeoutControl._lastTimestamp is initialized before anything that could set timeouts runs.
|
||||||
_timeoutControl.Initialize(_systemClock.UtcNow);
|
_timeoutControl.Initialize(_systemClock.UtcNow);
|
||||||
|
|
||||||
_context.ConnectionFeatures.Set<IConnectionTimeoutFeature>(_timeoutControl);
|
_context.ConnectionFeatures.Set<IConnectionTimeoutFeature>(_timeoutControl);
|
||||||
|
|
@ -375,7 +375,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
public void OnTimeout(TimeoutReason reason)
|
public void OnTimeout(TimeoutReason reason)
|
||||||
{
|
{
|
||||||
// In the cases that don't log directly here, we expect the setter of the timeout to also be the input
|
// In the cases that don't log directly here, we expect the setter of the timeout to also be the input
|
||||||
// reader, so when the read is canceled or arborted, the reader should write the appropriate log.
|
// reader, so when the read is canceled or aborted, the reader should write the appropriate log.
|
||||||
switch (reason)
|
switch (reason)
|
||||||
{
|
{
|
||||||
case TimeoutReason.KeepAlive:
|
case TimeoutReason.KeepAlive:
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,12 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Connections;
|
using Microsoft.AspNetCore.Connections;
|
||||||
using Microsoft.AspNetCore.Connections.Features;
|
using Microsoft.AspNetCore.Connections.Features;
|
||||||
using Microsoft.AspNetCore.Hosting.Server;
|
using Microsoft.AspNetCore.Hosting.Server;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var sslOptions = new SslServerAuthenticationOptions()
|
var sslOptions = new SslServerAuthenticationOptions
|
||||||
{
|
{
|
||||||
ServerCertificate = _serverCertificate,
|
ServerCertificate = _serverCertificate,
|
||||||
ServerCertificateSelectionCallback = selector,
|
ServerCertificateSelectionCallback = selector,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Connections;
|
using Microsoft.AspNetCore.Connections;
|
||||||
using Microsoft.AspNetCore.Hosting.Server;
|
using Microsoft.AspNetCore.Hosting.Server;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Connections;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
|
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Diagnostics.Tracing;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Connections;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
|
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics.Tracing;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Microsoft.AspNetCore.Connections;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
|
||||||
int portDelimiterEnd = portDelimiterStart + ":".Length;
|
int portDelimiterEnd = portDelimiterStart + ":".Length;
|
||||||
|
|
||||||
string portString = url.Substring(portDelimiterEnd, pathDelimiterStart - portDelimiterEnd);
|
string portString = url.Substring(portDelimiterEnd, pathDelimiterStart - portDelimiterEnd);
|
||||||
int portNumber;
|
if (int.TryParse(portString, NumberStyles.Integer, CultureInfo.InvariantCulture, out var portNumber))
|
||||||
if (int.TryParse(portString, NumberStyles.Integer, CultureInfo.InvariantCulture, out portNumber))
|
|
||||||
{
|
{
|
||||||
hasSpecifiedPort = true;
|
hasSpecifiedPort = true;
|
||||||
serverAddress.Host = url.Substring(schemeDelimiterEnd, portDelimiterStart - schemeDelimiterEnd);
|
serverAddress.Host = url.Substring(schemeDelimiterEnd, portDelimiterStart - schemeDelimiterEnd);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Buffers;
|
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
|
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Buffers;
|
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
|
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Connections.Features;
|
using Microsoft.AspNetCore.Connections.Features;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ using System.Runtime.ExceptionServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
||||||
|
|
||||||
if (_fileCompletionInfoPtr == IntPtr.Zero)
|
if (_fileCompletionInfoPtr == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
var fileCompletionInfo = new FILE_COMPLETION_INFORMATION() { Key = IntPtr.Zero, Port = IntPtr.Zero };
|
var fileCompletionInfo = new FILE_COMPLETION_INFORMATION { Key = IntPtr.Zero, Port = IntPtr.Zero };
|
||||||
_fileCompletionInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(fileCompletionInfo));
|
_fileCompletionInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(fileCompletionInfo));
|
||||||
Marshal.StructureToPtr(fileCompletionInfo, _fileCompletionInfoPtr, false);
|
Marshal.StructureToPtr(fileCompletionInfo, _fileCompletionInfoPtr, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
private UvException GetError(int statusCode)
|
private UvException GetError(int statusCode)
|
||||||
{
|
{
|
||||||
// Note: method marked as NoInlining so it doesn't bloat either of the two preceeding functions
|
// Note: method marked as NoInlining so it doesn't bloat either of the two preceding functions
|
||||||
// Check and ThrowError and alter their jit heuristics.
|
// Check and ThrowError and alter their jit heuristics.
|
||||||
var errorName = err_name(statusCode);
|
var errorName = err_name(statusCode);
|
||||||
var errorDescription = strerror(statusCode);
|
var errorDescription = strerror(statusCode);
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
|
||||||
|
|
||||||
public void Bind(IPEndPoint endPoint)
|
public void Bind(IPEndPoint endPoint)
|
||||||
{
|
{
|
||||||
SockAddr addr;
|
|
||||||
var addressText = endPoint.Address.ToString();
|
var addressText = endPoint.Address.ToString();
|
||||||
|
|
||||||
_uv.ip4_addr(addressText, endPoint.Port, out addr, out var error1);
|
_uv.ip4_addr(addressText, endPoint.Port, out var addr, out var error1);
|
||||||
|
|
||||||
if (error1 != null)
|
if (error1 != null)
|
||||||
{
|
{
|
||||||
|
|
@ -56,18 +55,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
|
||||||
|
|
||||||
public IPEndPoint GetPeerIPEndPoint()
|
public IPEndPoint GetPeerIPEndPoint()
|
||||||
{
|
{
|
||||||
SockAddr socketAddress;
|
|
||||||
int namelen = Marshal.SizeOf<SockAddr>();
|
int namelen = Marshal.SizeOf<SockAddr>();
|
||||||
_uv.tcp_getpeername(this, out socketAddress, ref namelen);
|
_uv.tcp_getpeername(this, out var socketAddress, ref namelen);
|
||||||
|
|
||||||
return socketAddress.GetIPEndPoint();
|
return socketAddress.GetIPEndPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPEndPoint GetSockIPEndPoint()
|
public IPEndPoint GetSockIPEndPoint()
|
||||||
{
|
{
|
||||||
SockAddr socketAddress;
|
|
||||||
int namelen = Marshal.SizeOf<SockAddr>();
|
int namelen = Marshal.SizeOf<SockAddr>();
|
||||||
_uv.tcp_getsockname(this, out socketAddress, ref namelen);
|
_uv.tcp_getsockname(this, out var socketAddress, ref namelen);
|
||||||
|
|
||||||
return socketAddress.GetIPEndPoint();
|
return socketAddress.GetIPEndPoint();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ namespace System.Buffers.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void PeekReturnsMinuOneByteInTheEnd()
|
public void PeekReturnsMinusOneByteInTheEnd()
|
||||||
{
|
{
|
||||||
var reader = new BufferReader(Factory.CreateWithContent(new byte[] { 1, 2 }));
|
var reader = new BufferReader(Factory.CreateWithContent(new byte[] { 1, 2 }));
|
||||||
Assert.Equal(1, reader.Read());
|
Assert.Equal(1, reader.Read());
|
||||||
|
|
@ -221,7 +221,7 @@ namespace System.Buffers.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void PeekWorkesWithEmptySegments()
|
public void PeekWorksWithEmptySegments()
|
||||||
{
|
{
|
||||||
var buffer = Factory.CreateWithContent(new byte[] { 1 });
|
var buffer = Factory.CreateWithContent(new byte[] { 1 });
|
||||||
var reader = new BufferReader(buffer);
|
var reader = new BufferReader(buffer);
|
||||||
|
|
@ -235,7 +235,7 @@ namespace System.Buffers.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void WorkesWithEmptyBuffer()
|
public void WorksWithEmptyBuffer()
|
||||||
{
|
{
|
||||||
var reader = new BufferReader(Factory.CreateWithContent(new byte[] { }));
|
var reader = new BufferReader(Factory.CreateWithContent(new byte[] { }));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace System.IO.Pipelines.Tests
|
namespace System.IO.Pipelines.Tests
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
var tcs = new TaskCompletionSource<object>();
|
var tcs = new TaskCompletionSource<object>();
|
||||||
var dispatcher = new ConnectionDispatcher(serviceContext, _ => tcs.Task);
|
var dispatcher = new ConnectionDispatcher(serviceContext, _ => tcs.Task);
|
||||||
|
|
||||||
var connection = new Mock<TransportConnection>() { CallBase = true }.Object;
|
var connection = new Mock<TransportConnection> { CallBase = true }.Object;
|
||||||
connection.ConnectionClosed = new CancellationToken(canceled: true);
|
connection.ConnectionClosed = new CancellationToken(canceled: true);
|
||||||
|
|
||||||
dispatcher.OnConnection(connection);
|
dispatcher.OnConnection(connection);
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
var serviceContext = new TestServiceContext();
|
var serviceContext = new TestServiceContext();
|
||||||
var dispatcher = new ConnectionDispatcher(serviceContext, _ => Task.CompletedTask);
|
var dispatcher = new ConnectionDispatcher(serviceContext, _ => Task.CompletedTask);
|
||||||
|
|
||||||
var mockConnection = new Mock<TransportConnection>() { CallBase = true };
|
var mockConnection = new Mock<TransportConnection> { CallBase = true };
|
||||||
mockConnection.Object.ConnectionClosed = new CancellationToken(canceled: true);
|
mockConnection.Object.ConnectionClosed = new CancellationToken(canceled: true);
|
||||||
var mockPipeReader = new Mock<PipeReader>();
|
var mockPipeReader = new Mock<PipeReader>();
|
||||||
var mockPipeWriter = new Mock<PipeWriter>();
|
var mockPipeWriter = new Mock<PipeWriter>();
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
|
|
||||||
var testKestrelTrace = new TestKestrelTrace();
|
var testKestrelTrace = new TestKestrelTrace();
|
||||||
|
|
||||||
using (var heatbeat = new Heartbeat(new IHeartbeatHandler[] { dateHeaderValueManager }, systemClock, DebuggerWrapper.Singleton, testKestrelTrace))
|
using (var heartbeat = new Heartbeat(new IHeartbeatHandler[] { dateHeaderValueManager }, systemClock, DebuggerWrapper.Singleton, testKestrelTrace))
|
||||||
{
|
{
|
||||||
heatbeat.OnHeartbeat();
|
heartbeat.OnHeartbeat();
|
||||||
Assert.Equal(now.ToString(Rfc1123DateFormat), dateHeaderValueManager.GetDateHeaderValues().String);
|
Assert.Equal(now.ToString(Rfc1123DateFormat), dateHeaderValueManager.GetDateHeaderValues().String);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Microsoft.AspNetCore.Connections;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
||||||
using Microsoft.AspNetCore.Testing;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,9 +225,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
{
|
{
|
||||||
IDictionary<string, StringValues> headers = httpHeaders;
|
IDictionary<string, StringValues> headers = httpHeaders;
|
||||||
|
|
||||||
StringValues value;
|
Assert.False(headers.TryGetValue("Content-Length", out var value));
|
||||||
|
|
||||||
Assert.False(headers.TryGetValue("Content-Length", out value));
|
|
||||||
Assert.Null(httpHeaders.ContentLength);
|
Assert.Null(httpHeaders.ContentLength);
|
||||||
Assert.False(httpHeaders.ContentLength.HasValue);
|
Assert.False(httpHeaders.ContentLength.HasValue);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
var block = new Span<byte>(Encoding.ASCII.GetBytes(input));
|
var block = new Span<byte>(Encoding.ASCII.GetBytes(input));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
HttpMethod knownMethod;
|
var result = block.GetKnownMethod(out var knownMethod, out var length);
|
||||||
var result = block.GetKnownMethod(out knownMethod, out var length);
|
|
||||||
|
|
||||||
string toString = null;
|
string toString = null;
|
||||||
if (knownMethod != HttpMethod.Custom)
|
if (knownMethod != HttpMethod.Custom)
|
||||||
|
|
@ -136,7 +135,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return new TheoryData<string>() {
|
return new TheoryData<string> {
|
||||||
"z",
|
"z",
|
||||||
"1",
|
"1",
|
||||||
"y:1",
|
"y:1",
|
||||||
|
|
@ -178,7 +177,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// see https://tools.ietf.org/html/rfc7230#section-5.4
|
// see https://tools.ietf.org/html/rfc7230#section-5.4
|
||||||
var data = new TheoryData<string>() {
|
var data = new TheoryData<string> {
|
||||||
"[]", // Too short
|
"[]", // Too short
|
||||||
"[::]", // Too short
|
"[::]", // Too short
|
||||||
"[ghijkl]", // Non-hex
|
"[ghijkl]", // Non-hex
|
||||||
|
|
|
||||||
|
|
@ -390,7 +390,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void StartingServerInitializesHeartbeat()
|
public void StartingServerInitializesHeartbeat()
|
||||||
{
|
{
|
||||||
var testContext = new TestServiceContext()
|
var testContext = new TestServiceContext
|
||||||
{
|
{
|
||||||
ServerOptions =
|
ServerOptions =
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||||
static byte[] _methodOptions = Encoding.ASCII.GetBytes("OPTIONS ");
|
static byte[] _methodOptions = Encoding.ASCII.GetBytes("OPTIONS ");
|
||||||
static byte[] _methodTrace = Encoding.ASCII.GetBytes("TRACE \0\0");
|
static byte[] _methodTrace = Encoding.ASCII.GetBytes("TRACE \0\0");
|
||||||
|
|
||||||
const int MagicNumer = 0x0600000C;
|
const int MagicNumber = 0x0600000C;
|
||||||
static byte[] _invalidMethod1 = BitConverter.GetBytes((ulong)MagicNumer);
|
static byte[] _invalidMethod1 = BitConverter.GetBytes((ulong)MagicNumber);
|
||||||
static byte[] _invalidMethod2 = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
static byte[] _invalidMethod2 = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||||
static byte[] _invalidMethod3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
static byte[] _invalidMethod3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||||
static byte[] _invalidMethod4 = Encoding.ASCII.GetBytes("CONNECT_");
|
static byte[] _invalidMethod4 = Encoding.ASCII.GetBytes("CONNECT_");
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
|
|
||||||
using Microsoft.AspNetCore.Testing;
|
using Microsoft.AspNetCore.Testing;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -26,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
var localhostListenOptions = new LocalhostListenOptions(1004);
|
var localhostListenOptions = new LocalhostListenOptions(1004);
|
||||||
localhostListenOptions.ConnectionAdapters.Add(new PassThroughConnectionAdapter());
|
localhostListenOptions.ConnectionAdapters.Add(new PassThroughConnectionAdapter());
|
||||||
var serviceProvider = new ServiceCollection().BuildServiceProvider();
|
var serviceProvider = new ServiceCollection().BuildServiceProvider();
|
||||||
localhostListenOptions.KestrelServerOptions = new KestrelServerOptions()
|
localhostListenOptions.KestrelServerOptions = new KestrelServerOptions
|
||||||
{
|
{
|
||||||
ApplicationServices = serviceProvider
|
ApplicationServices = serviceProvider
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -407,7 +407,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
{
|
{
|
||||||
var writeCount = 0;
|
var writeCount = 0;
|
||||||
var writeTcs = new TaskCompletionSource<(byte[], int, int)>(TaskCreationOptions.RunContinuationsAsynchronously);
|
var writeTcs = new TaskCompletionSource<(byte[], int, int)>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
var mockDestination = new Mock<Stream>() { CallBase = true };
|
var mockDestination = new Mock<Stream> { CallBase = true };
|
||||||
|
|
||||||
mockDestination
|
mockDestination
|
||||||
.Setup(m => m.WriteAsync(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>(), CancellationToken.None))
|
.Setup(m => m.WriteAsync(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>(), CancellationToken.None))
|
||||||
|
|
@ -443,8 +443,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
|
|
||||||
var bytes = Encoding.ASCII.GetBytes("Hello ");
|
var bytes = Encoding.ASCII.GetBytes("Hello ");
|
||||||
var buffer = http1Connection.RequestBodyPipe.Writer.GetMemory(2048);
|
var buffer = http1Connection.RequestBodyPipe.Writer.GetMemory(2048);
|
||||||
ArraySegment<byte> segment;
|
Assert.True(MemoryMarshal.TryGetArray(buffer, out ArraySegment<byte> segment));
|
||||||
Assert.True(MemoryMarshal.TryGetArray(buffer, out segment));
|
|
||||||
Buffer.BlockCopy(bytes, 0, segment.Array, segment.Offset, bytes.Length);
|
Buffer.BlockCopy(bytes, 0, segment.Array, segment.Offset, bytes.Length);
|
||||||
http1Connection.RequestBodyPipe.Writer.Advance(bytes.Length);
|
http1Connection.RequestBodyPipe.Writer.Advance(bytes.Length);
|
||||||
await http1Connection.RequestBodyPipe.Writer.FlushAsync();
|
await http1Connection.RequestBodyPipe.Writer.FlushAsync();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Buffers;
|
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
using System.Threading;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
||||||
using Microsoft.AspNetCore.Testing;
|
using Microsoft.AspNetCore.Testing;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTransport;
|
using Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTransport;
|
||||||
using Microsoft.AspNetCore.Testing;
|
using Microsoft.AspNetCore.Testing;
|
||||||
using Microsoft.Extensions.Logging.Testing;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
||||||
|
|
|
||||||
|
|
@ -1970,7 +1970,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
|
|
||||||
await SendRstStreamAsync(1);
|
await SendRstStreamAsync(1);
|
||||||
// Any paused writes for stream 1 should complete after an RST_STREAM
|
// Any paused writes for stream 1 should complete after an RST_STREAM
|
||||||
// even without any preceeding window updates.
|
// even without any preceding window updates.
|
||||||
await _runningStreams[1].Task.DefaultTimeout();
|
await _runningStreams[1].Task.DefaultTimeout();
|
||||||
|
|
||||||
// A connection-level window update allows the non-reset stream to continue.
|
// A connection-level window update allows the non-reset stream to continue.
|
||||||
|
|
@ -2771,7 +2771,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GOAWAY_Received_ContinuesAppsAwaitingStreamOutputFlowControle()
|
public async Task GOAWAY_Received_ContinuesAppsAwaitingStreamOutputFlowControl()
|
||||||
{
|
{
|
||||||
var writeTasks = new Task[6];
|
var writeTasks = new Task[6];
|
||||||
var initialWindowSize = _helloWorldBytes.Length / 2;
|
var initialWindowSize = _helloWorldBytes.Length / 2;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.ExceptionServices;
|
using System.Runtime.ExceptionServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Connections;
|
using Microsoft.AspNetCore.Connections;
|
||||||
|
|
@ -14,7 +13,6 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2;
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2;
|
||||||
using Microsoft.AspNetCore.Testing;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -43,7 +41,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task HEADERS_Received_InvlaidCustomMethod_Reset()
|
public async Task HEADERS_Received_InvalidCustomMethod_Reset()
|
||||||
{
|
{
|
||||||
var headers = new[]
|
var headers = new[]
|
||||||
{
|
{
|
||||||
|
|
@ -189,7 +187,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task HEADERS_Received_PathAndQuery_Seperated()
|
public async Task HEADERS_Received_PathAndQuery_Separated()
|
||||||
{
|
{
|
||||||
await InitializeConnectionAsync(context =>
|
await InitializeConnectionAsync(context =>
|
||||||
{
|
{
|
||||||
|
|
@ -1343,7 +1341,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ApplicationExeption_BeforeFirstWrite_Sends500()
|
public async Task ApplicationException_BeforeFirstWrite_Sends500()
|
||||||
{
|
{
|
||||||
var headers = new[]
|
var headers = new[]
|
||||||
{
|
{
|
||||||
|
|
@ -1380,7 +1378,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ApplicationExeption_AfterFirstWrite_Resets()
|
public async Task ApplicationException_AfterFirstWrite_Resets()
|
||||||
{
|
{
|
||||||
var headers = new[]
|
var headers = new[]
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.Http2
|
||||||
using (var connection = server.CreateConnection())
|
using (var connection = server.CreateConnection())
|
||||||
{
|
{
|
||||||
var sslStream = new SslStream(connection.Stream);
|
var sslStream = new SslStream(connection.Stream);
|
||||||
await sslStream.AuthenticateAsClientAsync(new SslClientAuthenticationOptions()
|
await sslStream.AuthenticateAsClientAsync(new SslClientAuthenticationOptions
|
||||||
{
|
{
|
||||||
TargetHost = "localhost",
|
TargetHost = "localhost",
|
||||||
RemoteCertificateValidationCallback = (_, __, ___, ____) => true,
|
RemoteCertificateValidationCallback = (_, __, ___, ____) => true,
|
||||||
ApplicationProtocols = new List<SslApplicationProtocol>() { SslApplicationProtocol.Http2, SslApplicationProtocol.Http11 },
|
ApplicationProtocols = new List<SslApplicationProtocol> { SslApplicationProtocol.Http2, SslApplicationProtocol.Http11 },
|
||||||
EnabledSslProtocols = SslProtocols.Tls11, // Intentionally less than the required 1.2
|
EnabledSslProtocols = SslProtocols.Tls11, // Intentionally less than the required 1.2
|
||||||
}, CancellationToken.None);
|
}, CancellationToken.None);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ReadCertificatesWhenEmptyCertificatsSection_ReturnsEmptyCollection()
|
public void ReadCertificatesWhenEmptyCertificatesSection_ReturnsEmptyCollection()
|
||||||
{
|
{
|
||||||
var config = new ConfigurationBuilder().AddInMemoryCollection(new[]
|
var config = new ConfigurationBuilder().AddInMemoryCollection(new[]
|
||||||
{
|
{
|
||||||
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ReadCertificatsSection_ReturnsCollection()
|
public void ReadCertificatesSection_ReturnsCollection()
|
||||||
{
|
{
|
||||||
var config = new ConfigurationBuilder().AddInMemoryCollection(new[]
|
var config = new ConfigurationBuilder().AddInMemoryCollection(new[]
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
|
||||||
var serverOptions = new KestrelServerOptions();
|
var serverOptions = new KestrelServerOptions();
|
||||||
serverOptions.ApplicationServices = new ServiceCollection()
|
serverOptions.ApplicationServices = new ServiceCollection()
|
||||||
.AddLogging()
|
.AddLogging()
|
||||||
.AddSingleton<IHostingEnvironment>(new HostingEnvironment() { ApplicationName = "TestApplication" })
|
.AddSingleton<IHostingEnvironment>(new HostingEnvironment { ApplicationName = "TestApplication" })
|
||||||
.BuildServiceProvider();
|
.BuildServiceProvider();
|
||||||
return serverOptions;
|
return serverOptions;
|
||||||
}
|
}
|
||||||
|
|
@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Configure_IsReplacable()
|
public void Configure_IsReplaceable()
|
||||||
{
|
{
|
||||||
var run1 = false;
|
var run1 = false;
|
||||||
var serverOptions = CreateServerOptions();
|
var serverOptions = CreateServerOptions();
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
||||||
skip = "https://github.com/aspnet/KestrelHttpServer/issues/2154";
|
skip = "https://github.com/aspnet/KestrelHttpServer/issues/2154";
|
||||||
}
|
}
|
||||||
|
|
||||||
dataset.Add(new H2SpecTestCase()
|
dataset.Add(new H2SpecTestCase
|
||||||
{
|
{
|
||||||
Id = testcase.Item1,
|
Id = testcase.Item1,
|
||||||
Description = testcase.Item2,
|
Description = testcase.Item2,
|
||||||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
||||||
Skip = skip,
|
Skip = skip,
|
||||||
});
|
});
|
||||||
|
|
||||||
dataset.Add(new H2SpecTestCase()
|
dataset.Add(new H2SpecTestCase
|
||||||
{
|
{
|
||||||
Id = testcase.Item1,
|
Id = testcase.Item1,
|
||||||
Description = testcase.Item2,
|
Description = testcase.Item2,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
#if NETCOREAPP2_2
|
#if NETCOREAPP2_2
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
|
|
@ -36,7 +35,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
// We don't want the default SocketsHttpHandler, it doesn't support HTTP/2 yet.
|
// We don't want the default SocketsHttpHandler, it doesn't support HTTP/2 yet.
|
||||||
Client = new HttpClient(new WinHttpHandler()
|
Client = new HttpClient(new WinHttpHandler
|
||||||
{
|
{
|
||||||
ServerCertificateValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
ServerCertificateValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#if NETCOREAPP2_2
|
#if NETCOREAPP2_2
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
|
@ -38,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
// We don't want the default SocketsHttpHandler, it doesn't support HTTP/2 yet.
|
// We don't want the default SocketsHttpHandler, it doesn't support HTTP/2 yet.
|
||||||
Client = new HttpClient(new WinHttpHandler()
|
Client = new HttpClient(new WinHttpHandler
|
||||||
{
|
{
|
||||||
ServerCertificateValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
ServerCertificateValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -177,17 +177,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
public async Task CanHandleMultipleConcurrentRequests()
|
public async Task CanHandleMultipleConcurrentRequests()
|
||||||
{
|
{
|
||||||
var requestNumber = 0;
|
var requestNumber = 0;
|
||||||
var ensureConcurrentReqeustTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
var ensureConcurrentRequestTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
|
||||||
using (var server = new TestServer(async context =>
|
using (var server = new TestServer(async context =>
|
||||||
{
|
{
|
||||||
if (Interlocked.Increment(ref requestNumber) == 1)
|
if (Interlocked.Increment(ref requestNumber) == 1)
|
||||||
{
|
{
|
||||||
await ensureConcurrentReqeustTcs.Task.DefaultTimeout();
|
await ensureConcurrentRequestTcs.Task.DefaultTimeout();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ensureConcurrentReqeustTcs.SetResult(null);
|
ensureConcurrentRequestTcs.SetResult(null);
|
||||||
}
|
}
|
||||||
}, new TestServiceContext(LoggerFactory)))
|
}, new TestServiceContext(LoggerFactory)))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Https.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Https.Internal;
|
||||||
using Microsoft.AspNetCore.Testing;
|
using Microsoft.AspNetCore.Testing;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
{
|
{
|
||||||
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
||||||
var mockLibuv = new MockLibuv();
|
var mockLibuv = new MockLibuv();
|
||||||
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
|
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
|
||||||
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
||||||
var thread = new LibuvThread(transport);
|
var thread = new LibuvThread(transport);
|
||||||
Task connectionTask = null;
|
Task connectionTask = null;
|
||||||
|
|
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
{
|
{
|
||||||
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
||||||
var mockLibuv = new MockLibuv();
|
var mockLibuv = new MockLibuv();
|
||||||
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
|
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
|
||||||
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
||||||
var thread = new LibuvThread(transport);
|
var thread = new LibuvThread(transport);
|
||||||
mockConnectionDispatcher.InputOptions = pool =>
|
mockConnectionDispatcher.InputOptions = pool =>
|
||||||
|
|
@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
{
|
{
|
||||||
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
||||||
var mockLibuv = new MockLibuv();
|
var mockLibuv = new MockLibuv();
|
||||||
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
|
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
|
||||||
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
||||||
var thread = new LibuvThread(transport);
|
var thread = new LibuvThread(transport);
|
||||||
var mockScheduler = new Mock<PipeScheduler>();
|
var mockScheduler = new Mock<PipeScheduler>();
|
||||||
|
|
@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
{
|
{
|
||||||
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
||||||
var mockLibuv = new MockLibuv();
|
var mockLibuv = new MockLibuv();
|
||||||
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
|
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
|
||||||
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
||||||
var thread = new LibuvThread(transport);
|
var thread = new LibuvThread(transport);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,6 @@ using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers;
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers;
|
||||||
using Microsoft.AspNetCore.Testing;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Moq;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
|
|
@ -20,7 +16,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
{
|
{
|
||||||
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
var mockConnectionDispatcher = new MockConnectionDispatcher();
|
||||||
var mockLibuv = new MockLibuv();
|
var mockLibuv = new MockLibuv();
|
||||||
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
|
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
|
||||||
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
var transport = new LibuvTransport(mockLibuv, transportContext, null);
|
||||||
var thread = new LibuvThread(transport);
|
var thread = new LibuvThread(transport);
|
||||||
var ranOne = false;
|
var ranOne = false;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
[InlineData(-1337)]
|
[InlineData(-1337)]
|
||||||
public void StartWithNonPositiveThreadCountThrows(int threadCount)
|
public void StartWithNonPositiveThreadCountThrows(int threadCount)
|
||||||
{
|
{
|
||||||
var options = new LibuvTransportOptions() { ThreadCount = threadCount };
|
var options = new LibuvTransportOptions { ThreadCount = threadCount };
|
||||||
|
|
||||||
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
|
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||||
new LibuvTransportFactory(Options.Create(options), new LifetimeNotImplemented(), Mock.Of<ILoggerFactory>()));
|
new LibuvTransportFactory(Options.Create(options), new LifetimeNotImplemented(), Mock.Of<ILoggerFactory>()));
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
var serviceContext = new TestServiceContext();
|
var serviceContext = new TestServiceContext();
|
||||||
listenOptions.UseHttpServer(listenOptions.ConnectionAdapters, serviceContext, new DummyApplication(TestApp.EchoApp), HttpProtocols.Http1);
|
listenOptions.UseHttpServer(listenOptions.ConnectionAdapters, serviceContext, new DummyApplication(TestApp.EchoApp), HttpProtocols.Http1);
|
||||||
|
|
||||||
var transportContext = new TestLibuvTransportContext()
|
var transportContext = new TestLibuvTransportContext
|
||||||
{
|
{
|
||||||
ConnectionDispatcher = new ConnectionDispatcher(serviceContext, listenOptions.Build())
|
ConnectionDispatcher = new ConnectionDispatcher(serviceContext, listenOptions.Build())
|
||||||
};
|
};
|
||||||
|
|
@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
|
|
||||||
listenOptions.UseHttpServer(listenOptions.ConnectionAdapters, serviceContext, testApplication, HttpProtocols.Http1);
|
listenOptions.UseHttpServer(listenOptions.ConnectionAdapters, serviceContext, testApplication, HttpProtocols.Http1);
|
||||||
|
|
||||||
var transportContext = new TestLibuvTransportContext()
|
var transportContext = new TestLibuvTransportContext
|
||||||
{
|
{
|
||||||
ConnectionDispatcher = new ConnectionDispatcher(serviceContext, listenOptions.Build()),
|
ConnectionDispatcher = new ConnectionDispatcher(serviceContext, listenOptions.Build()),
|
||||||
Options = new LibuvTransportOptions { ThreadCount = threadCount }
|
Options = new LibuvTransportOptions { ThreadCount = threadCount }
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
var serviceContextPrimary = new TestServiceContext();
|
var serviceContextPrimary = new TestServiceContext();
|
||||||
var builderPrimary = new ConnectionBuilder();
|
var builderPrimary = new ConnectionBuilder();
|
||||||
builderPrimary.UseHttpServer(serviceContextPrimary, new DummyApplication(c => c.Response.WriteAsync("Primary")), HttpProtocols.Http1);
|
builderPrimary.UseHttpServer(serviceContextPrimary, new DummyApplication(c => c.Response.WriteAsync("Primary")), HttpProtocols.Http1);
|
||||||
var transportContextPrimary = new TestLibuvTransportContext() { Log = new LibuvTrace(logger) };
|
var transportContextPrimary = new TestLibuvTransportContext { Log = new LibuvTrace(logger) };
|
||||||
transportContextPrimary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextPrimary, builderPrimary.Build());
|
transportContextPrimary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextPrimary, builderPrimary.Build());
|
||||||
|
|
||||||
var serviceContextSecondary = new TestServiceContext
|
var serviceContextSecondary = new TestServiceContext
|
||||||
|
|
@ -213,7 +213,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
||||||
var serviceContextPrimary = new TestServiceContext();
|
var serviceContextPrimary = new TestServiceContext();
|
||||||
var builderPrimary = new ConnectionBuilder();
|
var builderPrimary = new ConnectionBuilder();
|
||||||
builderPrimary.UseHttpServer(serviceContextPrimary, new DummyApplication(c => c.Response.WriteAsync("Primary")), HttpProtocols.Http1);
|
builderPrimary.UseHttpServer(serviceContextPrimary, new DummyApplication(c => c.Response.WriteAsync("Primary")), HttpProtocols.Http1);
|
||||||
var transportContextPrimary = new TestLibuvTransportContext() { Log = new LibuvTrace(logger) };
|
var transportContextPrimary = new TestLibuvTransportContext { Log = new LibuvTrace(logger) };
|
||||||
transportContextPrimary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextPrimary, builderPrimary.Build());
|
transportContextPrimary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextPrimary, builderPrimary.Build());
|
||||||
|
|
||||||
var serviceContextSecondary = new TestServiceContext
|
var serviceContextSecondary = new TestServiceContext
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Testing
|
namespace Microsoft.AspNetCore.Testing
|
||||||
|
|
@ -11,7 +10,7 @@ namespace Microsoft.AspNetCore.Testing
|
||||||
private readonly ILogger _testLogger;
|
private readonly ILogger _testLogger;
|
||||||
|
|
||||||
public KestrelTestLoggerProvider(bool throwOnCriticalErrors = true)
|
public KestrelTestLoggerProvider(bool throwOnCriticalErrors = true)
|
||||||
: this(new TestApplicationErrorLogger() { ThrowOnCriticalErrors = throwOnCriticalErrors })
|
: this(new TestApplicationErrorLogger { ThrowOnCriticalErrors = throwOnCriticalErrors })
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
public static IList<Tuple<string, string>> EnumerateTestCases()
|
public static IList<Tuple<string, string>> EnumerateTestCases()
|
||||||
{
|
{
|
||||||
var testCases = new List<Tuple<string, string>>();
|
var testCases = new List<Tuple<string, string>>();
|
||||||
var processOptions = new ProcessStartInfo()
|
var processOptions = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = GetToolLocation(),
|
FileName = GetToolLocation(),
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
|
|
@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
public static void RunTest(string testId, int port, bool https, ILogger logger)
|
public static void RunTest(string testId, int port, bool https, ILogger logger)
|
||||||
{
|
{
|
||||||
var tempFile = Path.GetTempPath() + Guid.NewGuid() + ".xml";
|
var tempFile = Path.GetTempPath() + Guid.NewGuid() + ".xml";
|
||||||
var processOptions = new ProcessStartInfo()
|
var processOptions = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = GetToolLocation(),
|
FileName = GetToolLocation(),
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue