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))]publicasyncTaskTest(){usingHttp2LoopbackServerserver=Http2LoopbackServer.CreateServer();usingHttpClientclient=CreateHttpClient();Task<HttpResponseMessage>sendTask=client.GetAsync(server.Address);Http2LoopbackConnectionconnection=awaitserver.AcceptConnectionAsync();awaitconnection.ReadSettingsAsync();awaitconnection.SendGoAway(0,ProtocolErrors.INTERNAL_ERROR);varex=awaitAssert.ThrowsAsync<HttpRequestException>(()=>sendTask);Assert.IsType<HttpProtocolException>(ex.InnerException);// Fails}
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
InnerExceptionof theHttpRequestExceptionbeing thrown must be aProtocolExceptionaccording to #70684.Instead, we embed
ProtocolExceptioninto furtherIOException-s 2 levels down inProcessIncomingFramesAsync().Repro: