Skip to content

Commit 4dc55d3

Browse files
rokonecpull[bot]
authored andcommitted
Added test for missing cookie header value (#103969)
* Test for missing cookie header value * Disable this unit test on net48
1 parent d573eb0 commit 4dc55d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ await LoopbackServerFactory.CreateClientAndServerAsync(
148148
});
149149
}
150150

151+
[Theory]
152+
[InlineData(null)]
153+
[InlineData("")]
154+
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, ".NET Framework allows empty value of cookie header while net7+ behaves by the specs and prohibit it")]
155+
public void AddCookieHeader_MissingValue_Throws(string? cookieValue)
156+
{
157+
var requestMessage = new HttpRequestMessage(HttpMethod.Get, "http://foo/bar") { Version = UseVersion };
158+
Assert.Throws<FormatException>(
159+
() => requestMessage.Headers.Add("Cookie", cookieValue)
160+
);
161+
}
162+
151163
[Fact]
152164
public async Task GetAsync_AddMultipleCookieHeaders_CookiesSent()
153165
{

0 commit comments

Comments
 (0)