There is an overlook in #71345. When the server doesn't initiate the connection with a proper SETTINGS preface, eg. responding by GOAWAY instead, the InnerException
of the HttpRequestException
being thrown must be a ProtocolException
according to #70684.
Instead, we embed ProtocolException
into further IOException
-s 2 levels down in ProcessIncomingFramesAsync()
.
Repro:
[ConditionalFact(nameof(SupportsAlpn))]
public async Task Test()
{
using Http2LoopbackServer server = Http2LoopbackServer.CreateServer();
using HttpClient client = CreateHttpClient();
Task<HttpResponseMessage> sendTask = client.GetAsync(server.Address);
Http2LoopbackConnection connection = await server.AcceptConnectionAsync();
await connection.ReadSettingsAsync();
await connection.SendGoAway(0, ProtocolErrors.INTERNAL_ERROR);
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => sendTask);
Assert.IsType<HttpProtocolException>(ex.InnerException); // Fails
}