Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] Update dependencies from dotnet/efcore dotnet/runtime #35547

Merged
merged 38 commits into from
Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a100832
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 20, 2021
903d164
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 20, 2021
d046abf
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 20, 2021
8566b38
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 20, 2021
2008974
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 20, 2021
903be6a
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 21, 2021
97d9233
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 21, 2021
10d5834
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 22, 2021
439b977
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 22, 2021
866e4df
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 23, 2021
b469ef0
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 23, 2021
93d559d
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 23, 2021
4fd1e36
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 24, 2021
6e4a318
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 24, 2021
1e7fe92
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 24, 2021
d233f5c
Respond to nullable annotations of `StringSegment`
dougbu Aug 24, 2021
5b9aa8a
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 24, 2021
9330eed
!fixup!
dougbu Aug 24, 2021
0c0378d
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 25, 2021
cb404b1
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 25, 2021
b908867
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 26, 2021
c4580c1
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 26, 2021
b19a7e8
Handle more nullable expressions
dougbu Aug 25, 2021
47ca366
Merge branch 'main' into darc-main-fcbf8a54-42e6-4ded-9535-034b26dfd6ba
dougbu Aug 27, 2021
5c65c52
Update dependencies from https://github.com/dotnet/efcore build 20210…
dotnet-maestro[bot] Aug 27, 2021
0dc7277
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 27, 2021
4bff1b7
Latest nullability updates
dougbu Aug 27, 2021
ab619a9
Remove some `StringSegment.Value` `null` forgiveness and extra handling
dougbu Aug 28, 2021
e3db44a
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 28, 2021
16a960b
!fixup! Handle `IsNullOrEmpty(...)` metadata lack
dougbu Aug 28, 2021
dbea160
!fixup! Use `ToString()` instead of suppression
dougbu Aug 28, 2021
9550049
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 28, 2021
9ac655f
Update `KnownHeaders`
dougbu Aug 29, 2021
543efec
Do generated JS files need to change?
dougbu Aug 29, 2021
992d844
!fixup! Allow `Charset` to be `null`
dougbu Aug 29, 2021
1404d93
Update dependencies from https://github.com/dotnet/runtime build 2021…
dotnet-maestro[bot] Aug 29, 2021
0d79864
!fixup! Adjust to fix failing tests
dougbu Aug 29, 2021
f484c66
!fixup! React to `HttpResponse.ContentType` change
dougbu Aug 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 140 additions & 140 deletions eng/Version.Details.xml

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions eng/Versions.props

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Components/Web.JS/dist/Release/blazor.server.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Components/Web.JS/dist/Release/blazor.webview.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Components/WebAssembly/Server/src/TargetPickerUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ Ensure your browser is running with debugging enabled.
<h2>Resolution</h2>
<p>
<h4>If you are using Google Chrome for your development, follow these instructions:</h4>
{GetLaunchChromeInstructions(targetApplicationUrl)}
{GetLaunchChromeInstructions(targetApplicationUrl.ToString())}
</p>
<p>
<h4>If you are using Microsoft Edge (80+) for your development, follow these instructions:</h4>
{GetLaunchEdgeInstructions(targetApplicationUrl)}
{GetLaunchEdgeInstructions(targetApplicationUrl.ToString())}
</p>
<strong>This should launch a new browser window with debugging enabled..</p>
<h2>Underlying exception:</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ManifestDirectoryInfo(ManifestDirectory directory, DateTimeOffset lastMod

public string? PhysicalPath => null;

public string? Name => Directory.Name;
public string Name => Directory.Name;

public DateTimeOffset LastModified { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ManifestFileInfo(Assembly assembly, ManifestFile file, DateTimeOffset las

public string? PhysicalPath => null;

public string? Name => ManifestFile.Name;
public string Name => ManifestFile.Name;

public DateTimeOffset LastModified { get; }

Expand Down
22 changes: 13 additions & 9 deletions src/Http/Headers/src/HeaderUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,24 +241,26 @@ public static bool TryParseSeconds(StringValues headerValues, string targetValue

for (var i = 0; i < headerValues.Count; i++)
{
var segment = headerValues[i]!;
dougbu marked this conversation as resolved.
Show resolved Hide resolved

// Trim leading white space
var current = HttpRuleParser.GetWhitespaceLength(headerValues[i], 0);
var current = HttpRuleParser.GetWhitespaceLength(segment, 0);

while (current < headerValues[i].Length)
while (current < segment.Length)
{
long seconds;
var initial = current;
var tokenLength = HttpRuleParser.GetTokenLength(headerValues[i], current);
if (tokenLength == targetValue.Length
&& string.Compare(headerValues[i], current, targetValue, 0, tokenLength, StringComparison.OrdinalIgnoreCase) == 0
&& TryParseNonNegativeInt64FromHeaderValue(current + tokenLength, headerValues[i], out seconds))
&& TryParseNonNegativeInt64FromHeaderValue(current + tokenLength, segment, out seconds))
{
// Token matches target value and seconds were parsed
value = TimeSpan.FromSeconds(seconds);
return true;
}

current = AdvanceCacheDirectiveIndex(current + tokenLength, headerValues[i]);
current = AdvanceCacheDirectiveIndex(current + tokenLength, segment);

// Ensure index was advanced
if (current <= initial)
Expand Down Expand Up @@ -295,22 +297,24 @@ public static bool ContainsCacheDirective(StringValues cacheControlDirectives, s

for (var i = 0; i < cacheControlDirectives.Count; i++)
{
var segment = cacheControlDirectives[i]!;
dougbu marked this conversation as resolved.
Show resolved Hide resolved

// Trim leading white space
var current = HttpRuleParser.GetWhitespaceLength(cacheControlDirectives[i], 0);
var current = HttpRuleParser.GetWhitespaceLength(segment, 0);

while (current < cacheControlDirectives[i].Length)
while (current < segment.Length)
{
var initial = current;

var tokenLength = HttpRuleParser.GetTokenLength(cacheControlDirectives[i], current);
var tokenLength = HttpRuleParser.GetTokenLength(segment, current);
if (tokenLength == targetDirectives.Length
&& string.Compare(cacheControlDirectives[i], current, targetDirectives, 0, tokenLength, StringComparison.OrdinalIgnoreCase) == 0)
&& string.Compare(segment, current, targetDirectives, 0, tokenLength, StringComparison.OrdinalIgnoreCase) == 0)
{
// Token matches target value
return true;
}

current = AdvanceCacheDirectiveIndex(current + tokenLength, cacheControlDirectives[i]);
current = AdvanceCacheDirectiveIndex(current + tokenLength, segment);

// Ensure index was advanced
if (current <= initial)
Expand Down
6 changes: 4 additions & 2 deletions src/Http/Headers/src/MediaTypeHeaderValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public StringSegment Charset
{
get
{
return NameValueHeaderValue.Find(_parameters, CharsetString)?.Value.Value;
return NameValueHeaderValue.Find(_parameters, CharsetString)?.Value ?? default;
}
set
{
dougbu marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -115,7 +115,9 @@ public Encoding? Encoding
get
{
var charset = Charset;
if (!StringSegment.IsNullOrEmpty(charset))

// Check HasValue; IsNullOrEmpty lacks [MemberNotNullWhen(false, nameof(Value))].
if (charset.HasValue && !StringSegment.IsNullOrEmpty(charset))
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public static void AppendCommaSeparatedValues(this IHeaderDictionary headers, st
/// <returns>the associated values from the collection separated into individual values, or StringValues.Empty if the key is not present.</returns>
public static string[] GetCommaSeparatedValues(this IHeaderDictionary headers, string key)
{
// GetHeaderSplit will return only non-null elements of the given IHeaderDictionary.
#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type.
return ParsingHelpers.GetHeaderSplit(headers, key).ToArray();
#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type.
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http.Abstractions/src/HostString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public string ToUriComponent()
GetParts(_value, out var host, out var port);

var mapping = new IdnMapping();
var encoded = mapping.GetAscii(host.Buffer, host.Offset, host.Length);
var encoded = mapping.GetAscii(host.Buffer!, host.Offset, host.Length);

return StringSegment.IsNullOrEmpty(port)
? encoded
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http.Abstractions/src/HttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public abstract class HttpResponse
/// <summary>
/// Gets or sets the value for the <c>Content-Type</c> response header.
/// </summary>
public abstract string ContentType { get; set; }
public abstract string? ContentType { get; set; }

/// <summary>
/// Gets an object that can be used to manage cookies for this response.
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Http.Abstractions/src/Internal/ParsingHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void SetHeaderJoined(IHeaderDictionary headers, string key, String
}

// Quote items that contain commas and are not already quoted.
private static string QuoteIfNeeded(string value)
private static string? QuoteIfNeeded(string? value)
{
if (!string.IsNullOrEmpty(value) &&
value.Contains(',') &&
Expand All @@ -80,7 +80,7 @@ private static string QuoteIfNeeded(string value)
return value;
}

private static string DeQuote(string value)
private static string? DeQuote(string? value)
{
if (!string.IsNullOrEmpty(value) &&
(value.Length > 1 && value[0] == '"' && value[value.Length - 1] == '"'))
Expand Down Expand Up @@ -129,7 +129,7 @@ public static void AppendHeaderJoined(IHeaderDictionary headers, string key, par
return;
}

string existing = GetHeader(headers, key);
string? existing = GetHeader(headers, key);
if (existing == null)
{
SetHeaderJoined(headers, key, values);
Expand Down
2 changes: 2 additions & 0 deletions src/Http/Http.Abstractions/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*REMOVED*static Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.UseMiddleware(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, System.Type! middleware, params object![]! args) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
*REMOVED*static Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.UseMiddleware<TMiddleware>(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, params object![]! args) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
*REMOVED*abstract Microsoft.AspNetCore.Http.HttpRequest.ContentType.get -> string!
*REMOVED*abstract Microsoft.AspNetCore.Http.HttpResponse.ContentType.get -> string!
Microsoft.AspNetCore.Http.IResult
Microsoft.AspNetCore.Http.IResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task!
Microsoft.AspNetCore.Http.Metadata.IAcceptsMetadata
Expand All @@ -26,6 +27,7 @@ Microsoft.AspNetCore.Http.RequestDelegateResult.EndpointMetadata.get -> System.C
Microsoft.AspNetCore.Http.RequestDelegateResult.RequestDelegate.get -> Microsoft.AspNetCore.Http.RequestDelegate!
Microsoft.AspNetCore.Http.RequestDelegateResult.RequestDelegateResult(Microsoft.AspNetCore.Http.RequestDelegate! requestDelegate, System.Collections.Generic.IReadOnlyList<object!>! metadata) -> void
Microsoft.AspNetCore.Routing.RouteValueDictionary.TryAdd(string! key, object? value) -> bool
abstract Microsoft.AspNetCore.Http.HttpResponse.ContentType.get -> string?
static readonly Microsoft.AspNetCore.Http.HttpProtocol.Http09 -> string!
static Microsoft.AspNetCore.Http.HttpProtocol.IsHttp09(string! protocol) -> bool
abstract Microsoft.AspNetCore.Http.HttpRequest.ContentType.get -> string?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ internal static void SetDate(this IHeaderDictionary headers, string name, DateTi
if (KnownParsers.TryGetValue(typeof(T), out var temp))
{
var func = (Func<string, T>)temp;
return func(value);
return func(value.ToString());
}

return GetViaReflection<T>(value.ToString());
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http.Extensions/src/QueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public QueryBuilder(IEnumerable<KeyValuePair<string, string>> parameters)
/// </summary>
/// <param name="parameters">The parameters to initialize the instance with.</param>
public QueryBuilder(IEnumerable<KeyValuePair<string, StringValues>> parameters)
: this(parameters.SelectMany(kvp => kvp.Value, (kvp, v) => KeyValuePair.Create(kvp.Key, v)))
: this(parameters.SelectMany(kvp => kvp.Value, (kvp, v) => KeyValuePair.Create(kvp.Key, v ?? string.Empty)))
{

}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http.Extensions/src/RequestHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public HostString Host
{
get
{
return HostString.FromUriComponent(Headers.Host);
return HostString.FromUriComponent(Headers.Host.ToString());
}
set
{
Expand Down
10 changes: 2 additions & 8 deletions src/Http/Http/src/FormFile.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Net.Http.Headers;

namespace Microsoft.AspNetCore.Http
{
/// <summary>
Expand Down Expand Up @@ -42,7 +36,7 @@ public FormFile(Stream baseStream, long baseStreamOffset, long length, string na
/// </summary>
public string ContentDisposition
{
get { return Headers.ContentDisposition; }
get { return Headers.ContentDisposition.ToString(); }
set { Headers.ContentDisposition = value; }
}

Expand All @@ -51,7 +45,7 @@ public string ContentDisposition
/// </summary>
public string ContentType
{
get { return Headers.ContentType; }
get { return Headers.ContentType.ToString(); }
set { Headers.ContentType = value; }
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http/src/Internal/DefaultHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public override bool IsHttps

public override HostString Host
{
get { return HostString.FromUriComponent(Headers.Host); }
get { return HostString.FromUriComponent(Headers.Host.ToString()); }
set { Headers.Host = value.ToUriComponent(); }
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http/src/Internal/DefaultHttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public override long? ContentLength
set { Headers.ContentLength = value; }
}

public override string ContentType
public override string? ContentType
{
get
{
Expand Down
5 changes: 3 additions & 2 deletions src/Http/Http/src/Internal/ResponseCookies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,10 @@ public void Delete(string key, CookieOptions options)

for (var i = 0; i < values.Length; i++)
{
if (!rejectPredicate(values[i], encodedKeyPlusEquals, options))
var value = values[i]!;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

if (!rejectPredicate(value, encodedKeyPlusEquals, options))
{
newValues.Add(values[i]);
newValues.Add(value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Routing/src/DataSourceDependentCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal sealed class DataSourceDependentCache<T> : IDisposable where T : class
private readonly EndpointDataSource _dataSource;
private readonly Func<IReadOnlyList<Endpoint>, T> _initializeCore;
private readonly Func<T> _initializer;
private readonly Action<object> _initializerWithState;
private readonly Action<object?> _initializerWithState;

private object _lock;
private bool _initialized;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override int GetDestination(HttpContext httpContext)
var httpMethod = httpContext.Request.Method;
if (_supportsCorsPreflight && HttpMethodMatcherPolicy.IsCorsPreflightRequest(httpContext, httpMethod, out var accessControlRequestMethod))
{
return _corsPreflightDestinations!.TryGetValue(accessControlRequestMethod, out destination)
return _corsPreflightDestinations!.TryGetValue(accessControlRequestMethod.ToString(), out destination)
? destination
: _corsPreflightExitDestination;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Routing/src/Matching/HttpMethodMatcherPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public Task ApplyAsync(HttpContext httpContext, CandidateSet candidates)
!StringValues.IsNullOrEmpty(accessControlRequestMethod))
{
needs405Endpoint = false; // We don't return a 405 for a CORS preflight request when the endpoints accept CORS preflight.
httpMethod = accessControlRequestMethod;
httpMethod = accessControlRequestMethod.ToString();
}

var matched = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override int GetDestination(HttpContext httpContext)
var httpMethod = httpContext.Request.Method;
if (_supportsCorsPreflight && HttpMethodMatcherPolicy.IsCorsPreflightRequest(httpContext, httpMethod, out var accessControlRequestMethod))
{
return HttpMethods.Equals(accessControlRequestMethod, _method) ? _corsPreflightDestination : _corsPreflightExitDestination;
return HttpMethods.Equals(accessControlRequestMethod.ToString(), _method) ? _corsPreflightDestination : _corsPreflightExitDestination;
}

return HttpMethods.Equals(httpMethod, _method) ? _destination : _exitDestination;
Expand Down
11 changes: 3 additions & 8 deletions src/Http/Shared/CookieHeaderParserShared.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using Microsoft.Extensions.Primitives;
Expand Down Expand Up @@ -31,12 +29,9 @@ public static bool TryParseValues(StringValues values, IDictionary<string, strin
if (TryParseValue(value, ref index, supportsMultipleValues, out var parsedName, out var parsedValue))
{
// The entry may not contain an actual value, like " , "
if (parsedName != null && parsedValue != null)
{
var name = enableCookieNameEncoding ? Uri.UnescapeDataString(parsedName.Value.Value) : parsedName.Value.Value;
store[name] = Uri.UnescapeDataString(parsedValue.Value.Value);
hasFoundValue = true;
}
Comment on lines -34 to -39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert. TryParseValue's [NotNullWhen(true)] markers are wrong, remove them. The parsedName and parsedValue can be null when supportsMultipleValues = true.

var name = enableCookieNameEncoding ? Uri.UnescapeDataString(parsedName.Value.Value!) : parsedName.Value.Value!;
store[name] = Uri.UnescapeDataString(parsedValue.Value.Value!);
hasFoundValue = true;
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions src/Http/WebUtilities/src/KeyValueAccumulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public void Append(string key, string value)
StringValues values;
if (_accumulator.TryGetValue(key, out values))
{
if (values.Count == 0)
if (StringValues.IsNullOrEmpty(values))
{
// Marker entry for this key to indicate entry already in expanding list dictionary
_expandingAccumulator[key].Add(value);
}
else if (values.Count == 1)
{
// Second value for this key
_accumulator[key] = new string[] { values[0], value };
_accumulator[key] = new string[] { values[0]!, value };
}
else
{
Expand All @@ -55,8 +55,8 @@ public void Append(string key, string value)
var list = new List<string>(8);
var array = values.ToArray();

list.Add(array[0]);
list.Add(array[1]);
list.Add(array[0]!);
list.Add(array[1]!);
list.Add(value);

_expandingAccumulator[key] = list;
Expand Down
9 changes: 5 additions & 4 deletions src/Middleware/CORS/src/Infrastructure/CorsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private static void PopulateResult(HttpContext context, CorsPolicy policy, CorsR
AddHeaderValues(result.AllowedExposedHeaders, policy.ExposedHeaders);

var allowedMethods = policy.AllowAnyMethod ?
new[] { result.IsPreflightRequest ? (string)headers.AccessControlRequestMethod : context.Request.Method } :
new[] { result.IsPreflightRequest ? headers.AccessControlRequestMethod.ToString() : context.Request.Method } :
policy.Methods;
AddHeaderValues(result.AllowedMethods, allowedMethods);

Expand Down Expand Up @@ -253,14 +253,15 @@ private bool IsOriginAllowed(CorsPolicy policy, StringValues origin)
return false;
}

_logger.RequestHasOriginHeader(origin);
if (policy.AllowAnyOrigin || policy.IsOriginAllowed(origin))
var originString = origin.ToString();
_logger.RequestHasOriginHeader(originString);
if (policy.AllowAnyOrigin || policy.IsOriginAllowed(originString))
{
_logger.PolicySuccess();
return true;
}
_logger.PolicyFailure();
_logger.OriginNotAllowed(origin);
_logger.OriginNotAllowed(originString);
return false;
}
}
Expand Down
Loading