@@ -340,6 +340,7 @@ await LoopbackServerFactory.CreateServerAsync(async (server, url) =>
340340 [ InlineData ( "nocolon" ) ]
341341 [ InlineData ( "no colon" ) ]
342342 [ InlineData ( "Content-Length " ) ]
343+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/54160" , TestPlatforms . Browser ) ]
343344 public async Task GetAsync_InvalidHeaderNameValue_ThrowsHttpRequestException ( string invalidHeader )
344345 {
345346 if ( UseVersion == HttpVersion30 )
@@ -353,14 +354,15 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
353354 {
354355 await Assert . ThrowsAsync < HttpRequestException > ( ( ) => client . GetStringAsync ( uri ) ) ;
355356 }
356- } , server => server . AcceptConnectionSendCustomResponseAndCloseAsync ( $ "HTTP/1.1 200 OK\r \n { invalidHeader } \r \n Content -Length: 11\r \n \r \n hello world") ) ;
357+ } , server => server . AcceptConnectionSendCustomResponseAndCloseAsync ( $ "HTTP/1.1 200 OK\r \n { invalidHeader } \r \n { LoopbackServer . CorsHeaders } Content -Length: 11\r \n \r \n hello world") ) ;
357358 }
358359
359360 [ Theory ]
360361 [ InlineData ( false , false ) ]
361362 [ InlineData ( true , false ) ]
362363 [ InlineData ( false , true ) ]
363364 [ InlineData ( true , true ) ]
365+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/54160" , TestPlatforms . Browser ) ]
364366 public async Task GetAsync_IncompleteData_ThrowsHttpRequestException ( bool failDuringHeaders , bool getString )
365367 {
366368 if ( IsWinHttpHandler )
@@ -384,11 +386,12 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
384386 }
385387 } , server =>
386388 failDuringHeaders ?
387- server . AcceptConnectionSendCustomResponseAndCloseAsync ( "HTTP/1.1 200 OK\r \n Content -Length: 5\r \n " ) :
388- server . AcceptConnectionSendCustomResponseAndCloseAsync ( "HTTP/1.1 200 OK\r \n Content -Length: 5\r \n \r \n he" ) ) ;
389+ server . AcceptConnectionSendCustomResponseAndCloseAsync ( $ "HTTP/1.1 200 OK\r \n { LoopbackServer . CorsHeaders } Content -Length: 5\r \n ") :
390+ server . AcceptConnectionSendCustomResponseAndCloseAsync ( $ "HTTP/1.1 200 OK\r \n { LoopbackServer . CorsHeaders } Content -Length: 5\r \n \r \n he") ) ;
389391 }
390392
391393 [ Fact ]
394+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/42852" , TestPlatforms . Browser ) ]
392395 public async Task PostAsync_ManyDifferentRequestHeaders_SentCorrectly ( )
393396 {
394397 if ( IsWinHttpHandler && UseVersion >= HttpVersion20 . Value )
@@ -577,7 +580,10 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
577580 {
578581 Assert . Equal ( "1.1" , resp . Version . ToString ( ) ) ;
579582 Assert . Equal ( HttpStatusCode . OK , resp . StatusCode ) ;
580- Assert . Contains ( "*" , resp . Headers . GetValues ( "Access-Control-Allow-Origin" ) ) ;
583+ if ( PlatformDetection . IsNotBrowser )
584+ {
585+ Assert . Contains ( "*" , resp . Headers . GetValues ( "Access-Control-Allow-Origin" ) ) ;
586+ }
581587 Assert . Contains ( "text/example;charset=utf-8" , resp . Headers . GetValues ( "Accept-Patch" ) ) ;
582588 Assert . Contains ( "bytes" , resp . Headers . AcceptRanges ) ;
583589 Assert . Equal ( TimeSpan . FromSeconds ( 12 ) , resp . Headers . Age . GetValueOrDefault ( ) ) ;
@@ -593,7 +599,10 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
593599 Assert . Contains ( "gzip" , resp . Content . Headers . ContentEncoding ) ;
594600 Assert . Contains ( "da" , resp . Content . Headers . ContentLanguage ) ;
595601 Assert . Equal ( new Uri ( "/index.htm" , UriKind . Relative ) , resp . Content . Headers . ContentLocation ) ;
596- Assert . Equal ( Convert . FromBase64String ( "Q2hlY2sgSW50ZWdyaXR5IQ==" ) , resp . Content . Headers . ContentMD5 ) ;
602+ if ( PlatformDetection . IsNotBrowser )
603+ {
604+ Assert . Equal ( Convert . FromBase64String ( "Q2hlY2sgSW50ZWdyaXR5IQ==" ) , resp . Content . Headers . ContentMD5 ) ;
605+ }
597606 Assert . Equal ( "bytes" , resp . Content . Headers . ContentRange . Unit ) ;
598607 Assert . Equal ( 21010 , resp . Content . Headers . ContentRange . From . GetValueOrDefault ( ) ) ;
599608 Assert . Equal ( 47021 , resp . Content . Headers . ContentRange . To . GetValueOrDefault ( ) ) ;
@@ -612,7 +621,11 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
612621 Assert . Contains ( "max-age=2592000; pin-sha256=\" E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=\" " , resp . Headers . GetValues ( "Public-Key-Pins" ) ) ;
613622 Assert . Equal ( TimeSpan . FromSeconds ( 120 ) , resp . Headers . RetryAfter . Delta . GetValueOrDefault ( ) ) ;
614623 Assert . Contains ( new ProductInfoHeaderValue ( "Apache" , "2.4.1" ) , resp . Headers . Server ) ;
615- Assert . Contains ( "UserID=JohnDoe; Max-Age=3600; Version=1" , resp . Headers . GetValues ( "Set-Cookie" ) ) ;
624+
625+ if ( PlatformDetection . IsNotBrowser )
626+ {
627+ Assert . Contains ( "UserID=JohnDoe; Max-Age=3600; Version=1" , resp . Headers . GetValues ( "Set-Cookie" ) ) ;
628+ }
616629 Assert . Contains ( "max-age=16070400; includeSubDomains" , resp . Headers . GetValues ( "Strict-Transport-Security" ) ) ;
617630 Assert . Contains ( "Max-Forwards" , resp . Headers . Trailer ) ;
618631 Assert . Contains ( "?" , resp . Headers . GetValues ( "Tk" ) ) ;
@@ -639,6 +652,7 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
639652 } , server => server . AcceptConnectionSendCustomResponseAndCloseAsync (
640653 $ "HTTP/1.1 200 OK{ newline } " +
641654 $ "Access-Control-Allow-Origin:{ fold } *{ newline } " +
655+ $ "Access-Control-Expose-Headers:{ fold } *{ newline } " +
642656 $ "Accept-Patch:{ fold } text/example;charset=utf-8{ newline } " +
643657 $ "Accept-Ranges:{ fold } bytes{ newline } " +
644658 $ "Age: { fold } 12{ newline } " +
@@ -693,6 +707,7 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
693707 dribble ? new LoopbackServer . Options { StreamWrapper = s => new DribbleStream ( s ) } : null ) ;
694708 }
695709
710+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/54160" , TestPlatforms . Browser ) ]
696711 [ Fact ]
697712 public async Task GetAsync_NonTraditionalChunkSizes_Accepted ( )
698713 {
@@ -712,6 +727,7 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
712727 server . AcceptConnectionSendCustomResponseAndCloseAsync (
713728 "HTTP/1.1 200 OK\r \n " +
714729 "Connection: close\r \n " +
730+ LoopbackServer . CorsHeaders +
715731 "Transfer-Encoding: chunked\r \n " +
716732 "\r \n " +
717733 "4 \r \n " + // whitespace after size
@@ -757,6 +773,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
757773 using ( HttpClient client = CreateHttpClient ( ) )
758774 {
759775 string partialResponse = "HTTP/1.1 200 OK\r \n " +
776+ LoopbackServer . CorsHeaders +
760777 "Transfer-Encoding: chunked\r \n " +
761778 "\r \n " +
762779 $ "{ chunkSize } \r \n ";
@@ -792,6 +809,7 @@ await LoopbackServer.CreateClientAndServerAsync(async url =>
792809 } , server => server . AcceptConnectionSendCustomResponseAndCloseAsync (
793810 "HTTP/1.1 200 OK\r \n " +
794811 "Connection: close\r \n " +
812+ LoopbackServer . CorsHeaders +
795813 "Transfer-Encoding: chunked\r \n " +
796814 "\r \n " +
797815 "5\r \n " +
@@ -820,7 +838,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
820838 var tcs = new TaskCompletionSource < bool > ( ) ;
821839 Task serverTask = server . AcceptConnectionAsync ( async connection =>
822840 {
823- await connection . ReadRequestHeaderAndSendCustomResponseAsync ( "HTTP/1.1 200 OK\r \n Transfer -Encoding: chunked\r \n \r \n " ) ;
841+ await connection . ReadRequestHeaderAndSendCustomResponseAsync ( "HTTP/1.1 200 OK\r \n " + LoopbackServer . CorsHeaders + "Transfer -Encoding: chunked\r \n \r \n ") ;
824842 try
825843 {
826844 while ( ! cts . IsCancellationRequested ) // infinite to make sure implementation doesn't OOM
@@ -840,6 +858,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
840858 }
841859
842860 [ Fact ]
861+ [ SkipOnPlatform ( TestPlatforms . Browser , "CORS is required on Browser" ) ]
843862 public async Task SendAsync_TransferEncodingSetButNoRequestContent_Throws ( )
844863 {
845864 var req = new HttpRequestMessage ( HttpMethod . Post , "http://bing.com" ) { Version = UseVersion } ;
@@ -871,6 +890,7 @@ await server.AcceptConnectionAsync(async connection =>
871890 await connection . ReadRequestHeaderAndSendCustomResponseAsync (
872891 "HTTP/1.1 200 OK\r \n " +
873892 $ "Date: { DateTimeOffset . UtcNow : R} \r \n " +
893+ LoopbackServer . CorsHeaders +
874894 "Content-Length: 16000\r \n " +
875895 "\r \n " +
876896 "less than 16000 bytes" ) ;
@@ -894,6 +914,7 @@ await connection.ReadRequestHeaderAndSendCustomResponseAsync(
894914 [ InlineData ( true ) ]
895915 [ InlineData ( false ) ]
896916 [ InlineData ( null ) ]
917+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/54159" , TestPlatforms . Browser ) ]
897918 public async Task ReadAsStreamAsync_HandlerProducesWellBehavedResponseStream ( bool ? chunked )
898919 {
899920 if ( IsWinHttpHandler && UseVersion >= HttpVersion20 . Value )
@@ -1059,6 +1080,7 @@ await server.AcceptConnectionAsync(async connection =>
10591080 }
10601081
10611082 [ Fact ]
1083+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/54159" , TestPlatforms . Browser ) ]
10621084 public async Task ReadAsStreamAsync_EmptyResponseBody_HandlerProducesWellBehavedResponseStream ( )
10631085 {
10641086 if ( IsWinHttpHandler && UseVersion >= HttpVersion20 . Value )
@@ -1223,6 +1245,7 @@ await LoopbackServerFactory.CreateServerAsync(async (server3, url3) =>
12231245 [ Theory ]
12241246 [ InlineData ( 99 ) ]
12251247 [ InlineData ( 1000 ) ]
1248+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/54160" , TestPlatforms . Browser ) ]
12261249 public async Task GetAsync_StatusCodeOutOfRange_ExpectedException ( int statusCode )
12271250 {
12281251 if ( UseVersion == HttpVersion30 )
@@ -1239,6 +1262,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
12391262 await server . AcceptConnectionSendCustomResponseAndCloseAsync (
12401263 $ "HTTP/1.1 { statusCode } \r \n " +
12411264 $ "Date: { DateTimeOffset . UtcNow : R} \r \n " +
1265+ LoopbackServer . CorsHeaders +
12421266 "Connection: close\r \n " +
12431267 "\r \n " ) ;
12441268
@@ -1267,6 +1291,7 @@ public async Task GetAsync_UnicodeHostName_SuccessStatusCodeInResponse()
12671291#region Post Methods Tests
12681292
12691293 [ Fact ]
1294+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/53876" , TestPlatforms . Browser ) ]
12701295 public async Task GetAsync_ExpectContinueTrue_NoContent_StillSendsHeader ( )
12711296 {
12721297 if ( IsWinHttpHandler && UseVersion >= HttpVersion20 . Value )
@@ -1493,6 +1518,7 @@ await server.AcceptConnectionAsync(async connection =>
14931518 }
14941519
14951520 [ Fact ]
1521+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/54160" , TestPlatforms . Browser ) ]
14961522 public async Task SendAsync_Expect100Continue_RequestBodyFails_ThrowsContentException ( )
14971523 {
14981524 if ( IsWinHttpHandler )
@@ -1589,6 +1615,7 @@ await server.AcceptConnectionAsync(async connection =>
15891615 }
15901616
15911617 [ Fact ]
1618+ [ SkipOnPlatform ( TestPlatforms . Browser , "Switching protocol is not supported on Browser" ) ]
15921619 public async Task SendAsync_101SwitchingProtocolsResponse_Success ( )
15931620 {
15941621 // WinHttpHandler and CurlHandler will hang, waiting for additional response.
@@ -1629,6 +1656,7 @@ await connection.ReadRequestHeaderAndSendCustomResponseAsync(
16291656 [ Theory ]
16301657 [ InlineData ( false ) ]
16311658 [ InlineData ( true ) ]
1659+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/54160" , TestPlatforms . Browser ) ]
16321660 public async Task PostAsync_ThrowFromContentCopy_RequestFails ( bool syncFailure )
16331661 {
16341662 if ( UseVersion == HttpVersion30 )
@@ -1664,6 +1692,7 @@ await LoopbackServer.CreateServerAsync(async (server, uri) =>
16641692 [ Theory ]
16651693 [ InlineData ( HttpStatusCode . MethodNotAllowed , "Custom description" ) ]
16661694 [ InlineData ( HttpStatusCode . MethodNotAllowed , "" ) ]
1695+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/54163" , TestPlatforms . Browser ) ]
16671696 public async Task GetAsync_CallMethod_ExpectedStatusLine ( HttpStatusCode statusCode , string reasonPhrase )
16681697 {
16691698 if ( LoopbackServerFactory . Version >= HttpVersion20 . Value )
@@ -1681,13 +1710,14 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
16811710 Assert . Equal ( reasonPhrase , response . ReasonPhrase ) ;
16821711 }
16831712 } , server => server . AcceptConnectionSendCustomResponseAndCloseAsync (
1684- $ "HTTP/1.1 { ( int ) statusCode } { reasonPhrase } \r \n Content -Length: 0\r \n \r \n ") ) ;
1713+ $ "HTTP/1.1 { ( int ) statusCode } { reasonPhrase } \r \n { LoopbackServer . CorsHeaders } Content -Length: 0\r \n \r \n ") ) ;
16851714 }
16861715
16871716 #endregion
16881717
16891718 #region Version tests
16901719
1720+ [ SkipOnPlatform ( TestPlatforms . Browser , "Version is not supported on Browser" ) ]
16911721 [ Fact ]
16921722 public async Task SendAsync_RequestVersion10_ServerReceivesVersion10Request ( )
16931723 {
@@ -1701,13 +1731,15 @@ public async Task SendAsync_RequestVersion10_ServerReceivesVersion10Request()
17011731 Assert . Equal ( new Version ( 1 , 0 ) , receivedRequestVersion ) ;
17021732 }
17031733
1734+ [ SkipOnPlatform ( TestPlatforms . Browser , "Version is not supported on Browser" ) ]
17041735 [ Fact ]
17051736 public async Task SendAsync_RequestVersion11_ServerReceivesVersion11Request ( )
17061737 {
17071738 Version receivedRequestVersion = await SendRequestAndGetRequestVersionAsync ( new Version ( 1 , 1 ) ) ;
17081739 Assert . Equal ( new Version ( 1 , 1 ) , receivedRequestVersion ) ;
17091740 }
17101741
1742+ [ SkipOnPlatform ( TestPlatforms . Browser , "Version is not supported on Browser" ) ]
17111743 [ Fact ]
17121744 public async Task SendAsync_RequestVersionNotSpecified_ServerReceivesVersion11Request ( )
17131745 {
0 commit comments