@@ -15,9 +15,6 @@ public class HttpProtocolTests : HttpClientTestBase
1515 protected virtual Stream GetStream ( Stream s ) => s ;
1616
1717 [ Theory ]
18- // The following disabled by ActiveIssue: 26540
19- // [InlineData("HTTP/1.1 200 ", 200, " ")]
20- // [InlineData("HTTP/1.1 200 Something", 200, " Something")]
2118 [ InlineData ( "HTTP/1.1 200 OK" , 200 , "OK" ) ]
2219 [ InlineData ( "HTTP/1.1 200 Sure why not?" , 200 , "Sure why not?" ) ]
2320 [ InlineData ( "HTTP/1.1 200 OK\x0080 " , 200 , "OK?" ) ]
@@ -35,6 +32,24 @@ public async Task GetAsync_ExpectedStatusCodeAndReason_Success(string statusLine
3532 await GetAsyncSuccessHelper ( statusLine , expectedStatusCode , expectedReason ) ;
3633 }
3734
35+ [ Theory ]
36+ [ InlineData ( "HTTP/1.1 200 " , 200 , " " , "" ) ]
37+ [ InlineData ( "HTTP/1.1 200 Something" , 200 , " Something" , "Something" ) ]
38+ public async Task GetAsync_ExpectedStatusCodeAndReason_PlatformBehaviorTest ( string statusLine ,
39+ int expectedStatusCode , string reasonWithSpace , string reasonNoSpace )
40+ {
41+ if ( UseManagedHandler || PlatformDetection . IsFullFramework )
42+ {
43+ // ManagedHandler and .NET Framework will keep the space characters.
44+ await GetAsyncSuccessHelper ( statusLine , expectedStatusCode , reasonWithSpace ) ;
45+ }
46+ else
47+ {
48+ // WinRT, WinHttpHandler, and CurlHandler will trim space characters.
49+ await GetAsyncSuccessHelper ( statusLine , expectedStatusCode , reasonNoSpace ) ;
50+ }
51+ }
52+
3853 [ Theory ]
3954 [ SkipOnTargetFramework ( TargetFrameworkMonikers . NetFramework , "The following pass on .NET Core but fail on .NET Framework." ) ]
4055 [ InlineData ( "HTTP/1.1 200" , 200 , "" ) ] // This test data requires the fix in .NET Framework 4.7.3
@@ -74,10 +89,6 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
7489 [ InlineData ( "HTTP/1.1 2345" ) ]
7590 [ InlineData ( "HTTP/A.1 200 OK" ) ]
7691 [ InlineData ( "HTTP/X.Y.Z 200 OK" ) ]
77- // The following disabled by ActiveIssue: 26542
78- //[InlineData("HTTP/1.1\t200 OK")]
79- //[InlineData("HTTP/1.1 200\tOK")]
80- //[InlineData("HTTP/1.1 200\t")]
8192 // TODO #24713: The following pass on Windows on .NET Core but fail on .NET Framework.
8293 //[InlineData("HTTP/0.1 200 OK")]
8394 //[InlineData("HTTP/3.5 200 OK")]
@@ -106,6 +117,25 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
106117 //[InlineData("HTTP/1.1 ")]
107118 //[InlineData("NOTHTTP/1.1 200 OK")]
108119 public async Task GetAsync_InvalidStatusLine_ThrowsException ( string responseString )
120+ {
121+ await GetAsyncThrowsExceptionHelper ( responseString ) ;
122+ }
123+
124+ [ Theory ]
125+ [ InlineData ( "HTTP/1.1\t 200 OK" ) ]
126+ [ InlineData ( "HTTP/1.1 200\t OK" ) ]
127+ [ InlineData ( "HTTP/1.1 200\t " ) ]
128+ public async Task GetAsync_InvalidStatusLine_ThrowsExceptionOnManagedHandler ( string responseString )
129+ {
130+ if ( UseManagedHandler || PlatformDetection . IsFullFramework )
131+ {
132+ // ManagedHandler and .NET Framework will throw HttpRequestException.
133+ await GetAsyncThrowsExceptionHelper ( responseString ) ;
134+ }
135+ // WinRT, WinHttpHandler, and CurlHandler will succeed.
136+ }
137+
138+ private async Task GetAsyncThrowsExceptionHelper ( string responseString )
109139 {
110140 await LoopbackServer . CreateServerAsync ( async ( server , url ) =>
111141 {
0 commit comments