6
6
using System . Linq ;
7
7
using System . Net . Http . Headers ;
8
8
using System . Net . Sockets ;
9
+ using System . Net . Quic ;
9
10
using System . Net . Test . Common ;
10
11
using System . Security . Authentication ;
11
12
using System . Security . Cryptography ;
@@ -267,7 +268,7 @@ await LoopbackServer.CreateClientAndServerAsync(async proxyUri =>
267
268
public static IEnumerable < object [ ] > SecureAndNonSecure_IPBasedUri_MemberData ( ) =>
268
269
from address in new [ ] { IPAddress . Loopback , IPAddress . IPv6Loopback }
269
270
from useSsl in BoolValues
270
- // we could not create SslStream in browser, [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)]
271
+ // we could not create SslStream in browser, [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)]
271
272
where PlatformDetection . IsNotBrowser || ! useSsl
272
273
select new object [ ] { address , useSsl } ;
273
274
@@ -877,8 +878,8 @@ await LoopbackServer.CreateClientAndServerAsync(async url =>
877
878
"\r \n " +
878
879
"5\r \n " +
879
880
"hello" + // missing \r\n terminator
880
- //"5\r\n" +
881
- //"world" + // missing \r\n terminator
881
+ //"5\r\n" +
882
+ //"world" + // missing \r\n terminator
882
883
"0\r \n " +
883
884
"\r \n " ) ) ;
884
885
}
@@ -1091,7 +1092,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
1091
1092
if ( PlatformDetection . IsBrowser )
1092
1093
{
1093
1094
#if ! NETFRAMEWORK
1094
- if ( slowChunks )
1095
+ if ( slowChunks )
1095
1096
{
1096
1097
Assert . Equal ( 1 , await responseStream . ReadAsync ( new Memory < byte > ( buffer2 ) ) ) ;
1097
1098
Assert . Equal ( ( byte ) 'h' , buffer2 [ 0 ] ) ;
@@ -1201,7 +1202,7 @@ await server.AcceptConnectionAsync(async connection =>
1201
1202
{
1202
1203
case true :
1203
1204
await connection . SendResponseAsync ( HttpStatusCode . OK , headers : new HttpHeaderData [ ] { new HttpHeaderData ( "Transfer-Encoding" , "chunked" ) } , isFinal : false ) ;
1204
- if ( PlatformDetection . IsBrowser && slowChunks )
1205
+ if ( PlatformDetection . IsBrowser && slowChunks )
1205
1206
{
1206
1207
await connection . SendResponseBodyAsync ( "1\r \n h\r \n " , false ) ;
1207
1208
await tcs . Task ;
@@ -1216,12 +1217,12 @@ await server.AcceptConnectionAsync(async connection =>
1216
1217
break ;
1217
1218
1218
1219
case false :
1219
- await connection . SendResponseAsync ( HttpStatusCode . OK , headers : new HttpHeaderData [ ] { new HttpHeaderData ( "Content-Length" , "11" ) } , content : "hello world" ) ;
1220
+ await connection . SendResponseAsync ( HttpStatusCode . OK , headers : new HttpHeaderData [ ] { new HttpHeaderData ( "Content-Length" , "11" ) } , content : "hello world" ) ;
1220
1221
break ;
1221
1222
1222
1223
case null :
1223
1224
// This inject Content-Length header with null value to hint Loopback code to not include one automatically.
1224
- await connection . SendResponseAsync ( HttpStatusCode . OK , headers : new HttpHeaderData [ ] { new HttpHeaderData ( "Content-Length" , null ) } , isFinal : false ) ;
1225
+ await connection . SendResponseAsync ( HttpStatusCode . OK , headers : new HttpHeaderData [ ] { new HttpHeaderData ( "Content-Length" , null ) } , isFinal : false ) ;
1225
1226
await connection . SendResponseBodyAsync ( "hello world" ) ;
1226
1227
break ;
1227
1228
}
@@ -1396,6 +1397,10 @@ await server.AcceptConnectionAsync(async connection =>
1396
1397
await connection . SendResponseAsync ( HttpStatusCode . OK , headers : new HttpHeaderData [ ] { new HttpHeaderData ( "Transfer-Encoding" , "chunked" ) } , isFinal : false ) ;
1397
1398
await connection . SendResponseBodyAsync ( "1\r \n h\r \n " , false ) ;
1398
1399
}
1400
+ catch ( QuicException ex ) when ( ex . ApplicationErrorCode == 0x10c /*H3_REQUEST_CANCELLED*/ )
1401
+ {
1402
+ // The request was cancelled before we sent the body, ignore
1403
+ }
1399
1404
catch ( IOException ex )
1400
1405
{
1401
1406
// when testing in the browser, we are using the WebSocket for the loopback
@@ -1450,10 +1455,10 @@ await LoopbackServerFactory.CreateServerAsync(async (server3, url3) =>
1450
1455
Task serverTask3 = server3 . AcceptConnectionAsync ( async connection3 =>
1451
1456
{
1452
1457
await connection3 . ReadRequestDataAsync ( ) ;
1453
- await connection3 . SendResponseAsync ( HttpStatusCode . OK , new HttpHeaderData [ ] { new HttpHeaderData ( "Content-Length" , "20" ) } , isFinal : false ) ;
1454
- await connection3 . SendResponseBodyAsync ( "1234567890" , isFinal : false ) ;
1458
+ await connection3 . SendResponseAsync ( HttpStatusCode . OK , new HttpHeaderData [ ] { new HttpHeaderData ( "Content-Length" , "20" ) } , isFinal : false ) ;
1459
+ await connection3 . SendResponseBodyAsync ( "1234567890" , isFinal : false ) ;
1455
1460
await unblockServers . Task ;
1456
- await connection3 . SendResponseBodyAsync ( "1234567890" , isFinal : true ) ;
1461
+ await connection3 . SendResponseBodyAsync ( "1234567890" , isFinal : true ) ;
1457
1462
} ) ;
1458
1463
1459
1464
// Make three requests
@@ -1527,7 +1532,7 @@ public async Task GetAsync_UnicodeHostName_SuccessStatusCodeInResponse()
1527
1532
}
1528
1533
}
1529
1534
1530
- #region Post Methods Tests
1535
+ #region Post Methods Tests
1531
1536
1532
1537
[ Fact ]
1533
1538
[ SkipOnPlatform ( TestPlatforms . Browser , "ExpectContinue not supported on Browser" ) ]
@@ -1571,13 +1576,13 @@ await server.AcceptConnectionAsync(async connection =>
1571
1576
1572
1577
public static IEnumerable < object [ ] > Interim1xxStatusCode ( )
1573
1578
{
1574
- yield return new object [ ] { ( HttpStatusCode ) 100 } ; // 100 Continue.
1579
+ yield return new object [ ] { ( HttpStatusCode ) 100 } ; // 100 Continue.
1575
1580
// 101 SwitchingProtocols will be treated as a final status code.
1576
- yield return new object [ ] { ( HttpStatusCode ) 102 } ; // 102 Processing.
1577
- yield return new object [ ] { ( HttpStatusCode ) 103 } ; // 103 EarlyHints.
1578
- yield return new object [ ] { ( HttpStatusCode ) 150 } ;
1579
- yield return new object [ ] { ( HttpStatusCode ) 180 } ;
1580
- yield return new object [ ] { ( HttpStatusCode ) 199 } ;
1581
+ yield return new object [ ] { ( HttpStatusCode ) 102 } ; // 102 Processing.
1582
+ yield return new object [ ] { ( HttpStatusCode ) 103 } ; // 103 EarlyHints.
1583
+ yield return new object [ ] { ( HttpStatusCode ) 150 } ;
1584
+ yield return new object [ ] { ( HttpStatusCode ) 180 } ;
1585
+ yield return new object [ ] { ( HttpStatusCode ) 199 } ;
1581
1586
}
1582
1587
1583
1588
[ Theory ]
@@ -1638,7 +1643,7 @@ await server.AcceptConnectionAsync(async connection =>
1638
1643
new HttpHeaderData ( "Content-type" , "text/xml" ) ,
1639
1644
new HttpHeaderData ( "Set-Cookie" , SetCookieIgnored1 ) } , isFinal : false ) ;
1640
1645
1641
- await connection . SendResponseAsync ( responseStatusCode , headers : new HttpHeaderData [ ] {
1646
+ await connection . SendResponseAsync ( responseStatusCode , headers : new HttpHeaderData [ ] {
1642
1647
new HttpHeaderData ( "Cookie" , "ignore_cookie=choco2" ) ,
1643
1648
new HttpHeaderData ( "Content-type" , "text/plain" ) ,
1644
1649
new HttpHeaderData ( "Set-Cookie" , SetCookieIgnored2 ) } , isFinal : false ) ;
@@ -1742,7 +1747,7 @@ await server.AcceptConnectionAsync(async connection =>
1742
1747
{
1743
1748
await connection . ReadRequestDataAsync ( readBody : false ) ;
1744
1749
// Send multiple 100-Continue responses.
1745
- for ( int count = 0 ; count < 4 ; count ++ )
1750
+ for ( int count = 0 ; count < 4 ; count ++ )
1746
1751
{
1747
1752
await connection . SendResponseAsync ( HttpStatusCode . Continue , isFinal : false ) ;
1748
1753
}
@@ -1846,7 +1851,7 @@ await server.AcceptConnectionAsync(async connection =>
1846
1851
{
1847
1852
await connection . ReadRequestDataAsync ( readBody : false ) ;
1848
1853
1849
- await connection . SendResponseAsync ( HttpStatusCode . OK , headers : new HttpHeaderData [ ] { new HttpHeaderData ( "Content-Length" , $ "{ ResponseString . Length } ") } , isFinal : false ) ;
1854
+ await connection . SendResponseAsync ( HttpStatusCode . OK , headers : new HttpHeaderData [ ] { new HttpHeaderData ( "Content-Length" , $ "{ ResponseString . Length } ") } , isFinal : false ) ;
1850
1855
1851
1856
byte [ ] body = await connection . ReadRequestBodyAsync ( ) ;
1852
1857
Assert . Equal ( RequestString , Encoding . ASCII . GetString ( body ) ) ;
@@ -2127,7 +2132,7 @@ await LoopbackServerFactory.CreateServerAsync(async (server, rootUrl) =>
2127
2132
}
2128
2133
} ) ;
2129
2134
}
2130
- #endregion
2135
+ #endregion
2131
2136
2132
2137
[ ConditionalFact ( typeof ( PlatformDetection ) , nameof ( PlatformDetection . IsNotBrowserDomSupported ) ) ]
2133
2138
public async Task GetAsync_InvalidUrl_ExpectedExceptionThrown ( )
0 commit comments