Skip to content

Commit 3aa6023

Browse files
committed
Expanded and fixed tests on Windows.
1 parent ee5a36a commit 3aa6023

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

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

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,14 +2156,20 @@ public async Task SendAsync_InvalidRequestUri_Throws()
21562156
[InlineData('\n', HeaderType.Request)]
21572157
[InlineData('\0', HeaderType.Request)]
21582158
[InlineData('\u0100', HeaderType.Request)]
2159+
[InlineData('\u0080', HeaderType.Request)]
2160+
[InlineData('\u009F', HeaderType.Request)]
21592161
[InlineData('\r', HeaderType.Content)]
21602162
[InlineData('\n', HeaderType.Content)]
21612163
[InlineData('\0', HeaderType.Content)]
21622164
[InlineData('\u0100', HeaderType.Content)]
2165+
[InlineData('\u0080', HeaderType.Content)]
2166+
[InlineData('\u009F', HeaderType.Content)]
21632167
[InlineData('\r', HeaderType.Cookie)]
21642168
[InlineData('\n', HeaderType.Cookie)]
21652169
[InlineData('\0', HeaderType.Cookie)]
21662170
[InlineData('\u0100', HeaderType.Cookie)]
2171+
[InlineData('\u0080', HeaderType.Cookie)]
2172+
[InlineData('\u009F', HeaderType.Cookie)]
21672173
public async Task SendAsync_RequestWithDangerousControlHeaderValue_ThrowsHttpRequestException(char dangerousChar, HeaderType headerType)
21682174
{
21692175
string uri = "https://example.com"; // URI doesn't matter, the request should never leave the client
@@ -2219,15 +2225,24 @@ public async Task SendAsync_RequestWithDangerousControlHeaderValue_ThrowsHttpReq
22192225
}
22202226

22212227
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))]
2228+
[InlineData('\u0001', HeaderType.Request)]
2229+
[InlineData('\u0007', HeaderType.Request)]
2230+
[InlineData('\u007F', HeaderType.Request)]
2231+
[InlineData('\u00A0', HeaderType.Request)]
22222232
[InlineData('\u00A9', HeaderType.Request)]
22232233
[InlineData('\u00FF', HeaderType.Request)]
2224-
[InlineData('\u0001', HeaderType.Request)]
2234+
[InlineData('\u0001', HeaderType.Content)]
2235+
[InlineData('\u0007', HeaderType.Content)]
2236+
[InlineData('\u007F', HeaderType.Content)]
2237+
[InlineData('\u00A0', HeaderType.Content)]
22252238
[InlineData('\u00A9', HeaderType.Content)]
22262239
[InlineData('\u00FF', HeaderType.Content)]
2227-
[InlineData('\u0001', HeaderType.Content)]
2240+
[InlineData('\u0001', HeaderType.Cookie)]
2241+
[InlineData('\u0007', HeaderType.Cookie)]
2242+
[InlineData('\u007F', HeaderType.Cookie)]
2243+
[InlineData('\u00A0', HeaderType.Cookie)]
22282244
[InlineData('\u00A9', HeaderType.Cookie)]
22292245
[InlineData('\u00FF', HeaderType.Cookie)]
2230-
[InlineData('\u0001', HeaderType.Cookie)]
22312246
public async Task SendAsync_RequestWithLatin1HeaderValue_Succeeds(char safeChar, HeaderType headerType)
22322247
{
22332248
if (!IsWinHttpHandler && safeChar > 0x7F)
@@ -2268,16 +2283,22 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
22682283
}, async server =>
22692284
{
22702285
var data = await server.AcceptConnectionSendResponseAndCloseAsync();
2286+
var expectedValue = headerValue;
2287+
if (safeChar > 0x7F)
2288+
{
2289+
Assert.True(IsWinHttpHandler);
2290+
expectedValue = headerValue.Replace(safeChar, '?'); // WinHttpHandler replaces Latin-1 characters with '?'.
2291+
}
22712292
switch (headerType)
22722293
{
22732294
case HeaderType.Request:
2274-
Assert.Equal(headerValue, data.GetSingleHeaderValue("Custom-Header"));
2295+
Assert.Equal(expectedValue, data.GetSingleHeaderValue("Custom-Header"));
22752296
break;
22762297
case HeaderType.Content:
2277-
Assert.Equal(headerValue, data.GetSingleHeaderValue("Custom-Content-Header"));
2298+
Assert.Equal(expectedValue, data.GetSingleHeaderValue("Custom-Content-Header"));
22782299
break;
22792300
case HeaderType.Cookie:
2280-
Assert.Equal($"CustomCookie={headerValue}", data.GetSingleHeaderValue("cookie"));
2301+
Assert.Equal($"CustomCookie={expectedValue}", data.GetSingleHeaderValue("cookie"));
22812302
break;
22822303
}
22832304
});

0 commit comments

Comments
 (0)