Preserve HTTP status codes across target frameworks (#1767)

Copilot-Session: 9a49da98-c8d8-4b90-a6ed-50afe18ac981
This commit is contained in:
Pranav Senthilnathan 2026-07-29 12:35:12 -07:00 • committed by GitHub
commit 5c305450cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -102,6 +102,10 @@ public class HttpClientTransportAutoDetectTests(ITestOutputHelper testOutputHelp
Assert.Contains("403", ex.Message);
Assert.IsType<HttpRequestException>(ex.InnerException);
Assert.Contains("405", ex.InnerException.Message);
Assert.Equal(HttpStatusCode.Forbidden, ex.Data["ModelContextProtocol.HttpStatusCode"]);
#if NET
Assert.Equal(HttpStatusCode.Forbidden, ex.StatusCode);
#endif
}
[Fact]
@ -410,6 +414,7 @@ public class HttpClientTransportAutoDetectTests(ITestOutputHelper testOutputHelp
var httpEx = Assert.IsType<HttpRequestException>(ex);
Assert.Contains("415", httpEx.Message);
Assert.Contains(streamableHttpBody, httpEx.Message);
Assert.Equal(HttpStatusCode.UnsupportedMediaType, httpEx.Data["ModelContextProtocol.HttpStatusCode"]);
#if NET
Assert.Equal(HttpStatusCode.UnsupportedMediaType, httpEx.StatusCode);
#endif