Skip to content

Commit ab3e803

Browse files
committed
Addressing feedback from asp.net team
1 parent 3a11950 commit ab3e803

File tree

8 files changed

+40
-29
lines changed

8 files changed

+40
-29
lines changed

src/Http/Http.Features/src/Microsoft.AspNetCore.Http.Features.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Nullable>enable</Nullable>
1111
</PropertyGroup>
1212

13-
<ItemGroup>
13+
<ItemGroup>
1414
<Reference Include="Microsoft.Extensions.Primitives" />
1515
<Reference Include="System.IO.Pipelines" />
1616
</ItemGroup>

src/Http/Http/src/Internal/ResponseCookies.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void Append(ReadOnlySpan<KeyValuePair<string, string>> keyValuePairs, Coo
101101
{
102102
if (_logger == null)
103103
{
104-
var services = _features.Get<Features.IServiceProvidersFeature>()?.RequestServices;
104+
var services = _features.Get<IServiceProvidersFeature>()?.RequestServices;
105105
_logger = services?.GetService<ILogger<ResponseCookies>>();
106106
}
107107

@@ -131,7 +131,8 @@ public void Append(ReadOnlySpan<KeyValuePair<string, string>> keyValuePairs, Coo
131131

132132
foreach (var keyValuePair in keyValuePairs)
133133
{
134-
cookies[position] = string.Concat(_enableCookieNameEncoding ? Uri.EscapeDataString(keyValuePair.Key) : keyValuePair.Key, "=", Uri.EscapeDataString(keyValuePair.Value), cookierHeaderValue);
134+
var key = _enableCookieNameEncoding ? Uri.EscapeDataString(keyValuePair.Key) : keyValuePair.Key;
135+
cookies[position] = string.Concat(key, "=", Uri.EscapeDataString(keyValuePair.Value), cookierHeaderValue);
135136
position++;
136137
}
137138

src/Mvc/Mvc.ViewFeatures/test/CookieTempDataProviderTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;

src/Security/CookiePolicy/src/ResponseCookiesWrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void Append(ReadOnlySpan<KeyValuePair<string, string>> keyValuePairs, Coo
161161
throw new ArgumentNullException(nameof(options));
162162
}
163163

164-
var nonSuppressedValues = new List<KeyValuePair<string, string>>();
164+
var nonSuppressedValues = new List<KeyValuePair<string, string>>(keyValuePairs.Length);
165165

166166
foreach (var keyValuePair in keyValuePairs)
167167
{

src/Security/CookiePolicy/test/CookieChunkingTests.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ public void DeleteChunkedCookieWithOptionsAndResponseCookies_AllDeleted()
157157

158158
httpContext.Request.Headers["Cookie"] = new[]
159159
{
160-
"TestCookie=chunks-7; domain=foo.com; path=/; secure",
161-
"TestCookieC1=abcdefghi; domain=foo.com; path=/; secure",
162-
"TestCookieC2=jklmnopqr; domain=foo.com; path=/; secure",
163-
"TestCookieC3=stuvwxyz0; domain=foo.com; path=/; secure",
164-
"TestCookieC4=123456789; domain=foo.com; path=/; secure",
165-
"TestCookieC5=ABCDEFGHI; domain=foo.com; path=/; secure",
166-
"TestCookieC6=JKLMNOPQR; domain=foo.com; path=/; secure",
167-
"TestCookieC7=STUVWXYZ; domain=foo.com; path=/; secure"
160+
"TestCookie=chunks-7",
161+
"TestCookieC1=abcdefghi",
162+
"TestCookieC2=jklmnopqr",
163+
"TestCookieC3=stuvwxyz0",
164+
"TestCookieC4=123456789",
165+
"TestCookieC5=ABCDEFGHI",
166+
"TestCookieC6=JKLMNOPQR",
167+
"TestCookieC7=STUVWXYZ"
168168
};
169169

170170
var cookieOptions = new CookieOptions()
@@ -177,8 +177,8 @@ public void DeleteChunkedCookieWithOptionsAndResponseCookies_AllDeleted()
177177
httpContext.Response.Headers[HeaderNames.SetCookie] = new[]
178178
{
179179
"TestCookie=chunks-7; domain=foo.com; path=/; secure",
180-
"TestCookieC1=abcdefghi; domain=foo.com; path=/; secure",
181-
"TestCookieC2=jklmnopqr; domain=foo.com; path=/; secure",
180+
"TestCookieC1=STUVWXYZ; domain=foo.com; path=/; secure",
181+
"TestCookieC2=123456789; domain=foo.com; path=/; secure",
182182
"TestCookieC3=stuvwxyz0; domain=foo.com; path=/; secure",
183183
"TestCookieC4=123456789; domain=foo.com; path=/; secure",
184184
"TestCookieC5=ABCDEFGHI; domain=foo.com; path=/; secure",
@@ -188,6 +188,17 @@ public void DeleteChunkedCookieWithOptionsAndResponseCookies_AllDeleted()
188188

189189
chunkingCookieManager.DeleteCookie(httpContext, "TestCookie", cookieOptions);
190190
Assert.Equal(8, httpContext.Response.Headers[HeaderNames.SetCookie].Count);
191+
Assert.Equal(new[]
192+
{
193+
"TestCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure",
194+
"TestCookieC1=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure",
195+
"TestCookieC2=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure",
196+
"TestCookieC3=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure",
197+
"TestCookieC4=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure",
198+
"TestCookieC5=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure",
199+
"TestCookieC6=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure",
200+
"TestCookieC7=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; secure"
201+
}, httpContext.Response.Headers[HeaderNames.SetCookie]);
191202
}
192203
}
193204
}

src/Security/CookiePolicy/test/CookiePolicyTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using System.Collections.Generic;
65
using System.Security.Claims;
76
using System.Security.Principal;
87
using System.Threading.Tasks;

src/Security/perf/Microbenchmarks/ChunkingCookieManagerBenchmark.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public void GlobalSetup()
3232

3333
_httpContext.Request.Headers["Cookie"] = new[]
3434
{
35-
"TestCookie=chunks-7; domain=foo.com; path=/; secure",
36-
"TestCookieC1=abcdefghi; domain=foo.com; path=/; secure",
37-
"TestCookieC2=jklmnopqr; domain=foo.com; path=/; secure",
38-
"TestCookieC3=stuvwxyz0; domain=foo.com; path=/; secure",
39-
"TestCookieC4=123456789; domain=foo.com; path=/; secure",
40-
"TestCookieC5=ABCDEFGHI; domain=foo.com; path=/; secure",
41-
"TestCookieC6=JKLMNOPQR; domain=foo.com; path=/; secure",
42-
"TestCookieC7=STUVWXYZ; domain=foo.com; path=/; secure"
35+
"TestCookie=chunks-7",
36+
"TestCookieC1=abcdefghi",
37+
"TestCookieC2=jklmnopqr",
38+
"TestCookieC3=stuvwxyz0",
39+
"TestCookieC4=123456789",
40+
"TestCookieC5=ABCDEFGHI",
41+
"TestCookieC6=JKLMNOPQR",
42+
"TestCookieC7=STUVWXYZ"
4343
};
4444

4545
_stringToAdd = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

src/Security/perf/Microbenchmarks/Microsoft.AspNetCore.Security.Microbenchmarks.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
55
<OutputType>Exe</OutputType>
66
<ServerGarbageCollection>true</ServerGarbageCollection>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<RootNamespace>Microsoft.AspNetCore.Security</RootNamespace>
99
</PropertyGroup>
10-
10+
1111
<ItemGroup>
12-
<Reference Include="Microsoft.AspNetCore.Authorization.Policy" />
1312
<Reference Include="BenchmarkDotNet" />
13+
<Reference Include="Microsoft.AspNetCore.Authorization.Policy" />
14+
<Reference Include="Microsoft.AspNetCore.Authentication.Cookies" />
1415
<Reference Include="Microsoft.AspNetCore.Http" />
1516
<Reference Include="Microsoft.Extensions.DependencyInjection" />
1617
<Reference Include="Microsoft.Extensions.Logging" />
17-
<Reference Include="Microsoft.AspNetCore.Authentication.Cookies" />
1818

1919
<Compile Include="$(SharedSourceRoot)BenchmarkRunner\*.cs" />
2020
</ItemGroup>

0 commit comments

Comments
 (0)