@@ -2156,14 +2156,20 @@ public async Task SendAsync_InvalidRequestUri_Throws()
2156
2156
[ InlineData ( '\n ' , HeaderType . Request ) ]
2157
2157
[ InlineData ( '\0 ' , HeaderType . Request ) ]
2158
2158
[ InlineData ( '\u0100 ' , HeaderType . Request ) ]
2159
+ [ InlineData ( '\u0080 ' , HeaderType . Request ) ]
2160
+ [ InlineData ( '\u009F ' , HeaderType . Request ) ]
2159
2161
[ InlineData ( '\r ' , HeaderType . Content ) ]
2160
2162
[ InlineData ( '\n ' , HeaderType . Content ) ]
2161
2163
[ InlineData ( '\0 ' , HeaderType . Content ) ]
2162
2164
[ InlineData ( '\u0100 ' , HeaderType . Content ) ]
2165
+ [ InlineData ( '\u0080 ' , HeaderType . Content ) ]
2166
+ [ InlineData ( '\u009F ' , HeaderType . Content ) ]
2163
2167
[ InlineData ( '\r ' , HeaderType . Cookie ) ]
2164
2168
[ InlineData ( '\n ' , HeaderType . Cookie ) ]
2165
2169
[ InlineData ( '\0 ' , HeaderType . Cookie ) ]
2166
2170
[ InlineData ( '\u0100 ' , HeaderType . Cookie ) ]
2171
+ [ InlineData ( '\u0080 ' , HeaderType . Cookie ) ]
2172
+ [ InlineData ( '\u009F ' , HeaderType . Cookie ) ]
2167
2173
public async Task SendAsync_RequestWithDangerousControlHeaderValue_ThrowsHttpRequestException ( char dangerousChar , HeaderType headerType )
2168
2174
{
2169
2175
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
2219
2225
}
2220
2226
2221
2227
[ 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 ) ]
2222
2232
[ InlineData ( '\u00A9 ' , HeaderType . Request ) ]
2223
2233
[ 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 ) ]
2225
2238
[ InlineData ( '\u00A9 ' , HeaderType . Content ) ]
2226
2239
[ 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 ) ]
2228
2244
[ InlineData ( '\u00A9 ' , HeaderType . Cookie ) ]
2229
2245
[ InlineData ( '\u00FF ' , HeaderType . Cookie ) ]
2230
- [ InlineData ( '\u0001 ' , HeaderType . Cookie ) ]
2231
2246
public async Task SendAsync_RequestWithLatin1HeaderValue_Succeeds ( char safeChar , HeaderType headerType )
2232
2247
{
2233
2248
if ( ! IsWinHttpHandler && safeChar > 0x7F )
@@ -2268,16 +2283,22 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
2268
2283
} , async server =>
2269
2284
{
2270
2285
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
+ }
2271
2292
switch ( headerType )
2272
2293
{
2273
2294
case HeaderType . Request :
2274
- Assert . Equal ( headerValue , data . GetSingleHeaderValue ( "Custom-Header" ) ) ;
2295
+ Assert . Equal ( expectedValue , data . GetSingleHeaderValue ( "Custom-Header" ) ) ;
2275
2296
break ;
2276
2297
case HeaderType . Content :
2277
- Assert . Equal ( headerValue , data . GetSingleHeaderValue ( "Custom-Content-Header" ) ) ;
2298
+ Assert . Equal ( expectedValue , data . GetSingleHeaderValue ( "Custom-Content-Header" ) ) ;
2278
2299
break ;
2279
2300
case HeaderType . Cookie :
2280
- Assert . Equal ( $ "CustomCookie={ headerValue } ", data . GetSingleHeaderValue ( "cookie" ) ) ;
2301
+ Assert . Equal ( $ "CustomCookie={ expectedValue } ", data . GetSingleHeaderValue ( "cookie" ) ) ;
2281
2302
break ;
2282
2303
}
2283
2304
} ) ;
0 commit comments