Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 851f68b

Browse files
committed
Duplication madness
1 parent 82f4a68 commit 851f68b

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

src/Microsoft.AspNetCore.Http/Internal/ResponseCookies.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void Append(string key, string value, CookieOptions options)
6262
Path = options.Path,
6363
Expires = options.Expires,
6464
Secure = options.Secure,
65-
SameSite = options.SameSite,
65+
SameSite = ConvertSameSiteEnforcementMode(options.SameSite),
6666
HttpOnly = options.HttpOnly
6767
};
6868

@@ -131,5 +131,20 @@ public void Delete(string key, CookieOptions options)
131131
Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc),
132132
});
133133
}
134+
135+
private Net.Http.Headers.SameSiteEnforcementMode ConvertSameSiteEnforcementMode(SameSiteEnforcementMode sameSite)
136+
{
137+
if (sameSite == SameSiteEnforcementMode.Lax)
138+
{
139+
return Net.Http.Headers.SameSiteEnforcementMode.Lax;
140+
}
141+
142+
if (sameSite == SameSiteEnforcementMode.Strict)
143+
{
144+
return Net.Http.Headers.SameSiteEnforcementMode.Strict;
145+
}
146+
147+
return Net.Http.Headers.SameSiteEnforcementMode.None;
148+
}
134149
}
135150
}

src/Microsoft.Net.Http.Headers/Microsoft.Net.Http.Headers.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
<EnableApiCheck>false</EnableApiCheck>
1313
</PropertyGroup>
1414

15-
<ItemGroup>
16-
<ProjectReference Include="..\Microsoft.AspNetCore.Http.Features\Microsoft.AspNetCore.Http.Features.csproj" />
17-
</ItemGroup>
18-
1915
<ItemGroup>
2016
<PackageReference Include="Microsoft.Extensions.Primitives" Version="$(AspNetCoreVersion)" />
2117
</ItemGroup>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
namespace Microsoft.Net.Http.Headers
5+
{
6+
public enum SameSiteEnforcementMode
7+
{
8+
None = 0,
9+
Lax,
10+
Strict
11+
}
12+
}

src/Microsoft.Net.Http.Headers/SetCookieHeaderValue.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Generic;
66
using System.Diagnostics.Contracts;
77
using System.Text;
8-
using Microsoft.AspNetCore.Http;
98
using Microsoft.Extensions.Primitives;
109

1110
namespace Microsoft.Net.Http.Headers

test/Microsoft.Net.Http.Headers.Tests/SetCookieHeaderValueTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using System.Text;
8-
using Microsoft.AspNetCore.Http;
98
using Xunit;
109

1110
namespace Microsoft.Net.Http.Headers

0 commit comments

Comments
 (0)