Skip to content

HttpProtocolException is not reported properly on initial HTTP/2 settings handshake failure #82168

Closed

Description

@antonfirsov

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
}

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Feb 15, 2023
  2. CarnaViire commented on Mar 14, 2023

    @CarnaViire
    Member

    Triage: this looks like something straightforward to fix. We should fix it in 8.0.

  3. added this to the 8.0.0 milestone on Mar 14, 2023
  4. ghost removed
    untriagedNew issue has not been triaged by the area owner
    on Mar 14, 2023
  5. modified the milestones: 8.0.0, Future on Jun 13, 2023
  6. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 17, 2023
  7. modified the milestones: Future, 9.0.0 on Jul 18, 2023
  8. added a commit that references this issue on Jul 18, 2023
    04bb7e5
  9. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 18, 2023
  10. modified the milestones: 9.0.0, 8.0.0 on Aug 1, 2023
  11. ghost locked as resolved and limited conversation to collaborators on Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions