Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Clean up HTTP/2 protocol exception handling#37223

Merged
stephentoub merged 2 commits intodotnet:masterfrom
stephentoub:http2protocolexception
Apr 29, 2019
Merged

Clean up HTTP/2 protocol exception handling#37223
stephentoub merged 2 commits intodotnet:masterfrom
stephentoub:http2protocolexception

Conversation

@stephentoub
Copy link
Copy Markdown
Member

  • Propagate the GOAWAY and RST_STREAM error codes to the calling code via an exception.
  • Propagate to the Http2Stream exceptions incurred in the Http2Connection and that result in an Abort.
  • Don't Dispose of the Http2Stream before we try to Cancel it.
  • Make Http2ProtocolException serializable, as we generally do that for all of our exception types.
  • Add tests that verify sufficient HTTP/2 protocol details are in the exception messages.
  • Clean up the error message for the exception.
  • Separate the error code and exception into their own files.
  • Leave Http2ProtocolException internal for now; we can expose it publicly when we design the all-up public error model for HttpClient.

cc: @geoffkizer, @davidsh, @wfurt
Fixes https://github.com/dotnet/corefx/issues/31315 (exposing error codes publicly should be handled as part of https://github.com/dotnet/corefx/issues/26477)

Comment thread src/System.Net.Http/src/System.Net.Http.csproj Outdated
Comment thread src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs Outdated
Comment thread src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs Outdated
Copy link
Copy Markdown
Contributor

@davidsh davidsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments. LGTM

Copy link
Copy Markdown
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@stephentoub stephentoub force-pushed the http2protocolexception branch from 460c7d0 to b5b3308 Compare April 27, 2019 18:41
@stephentoub
Copy link
Copy Markdown
Member Author

/azp run corefx-outerloop-linux

@stephentoub
Copy link
Copy Markdown
Member Author

/azp run corefx-outerloop-windows

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JamesNK
Copy link
Copy Markdown
Member

JamesNK commented Apr 28, 2019

This may be useful to gRPC. Some questions:

  1. Http2ProtocolException is still internal in this PR. Is the barrier to making it public going through an API review process?
  2. Where could this exception be thrown from? SendAsync, Write/Read on body streams, etc
  3. In the 3.0 timeframe could we expose the error code value via Exception.Data? Parsing it out of the exception message is an option but one I'd like to avoid.

@stephentoub
Copy link
Copy Markdown
Member Author

Is the barrier to making it public going through an API review process?

No, it's designing an error model that makes holistic sense, across both HTTP/1.1 and HTTP/2, and that serves the needs of everyone who's been asking for it. That's what #26477 tracks doing. I was hopeful it would happen for 3.0, but it currently doesn't look like it. I don't want to expose something just for HTTP/2 if it's not going to fit in well with that, and I don't think exposing another exception type is how we'd actually want this surfaced, more likely enums and properties.

@stephentoub
Copy link
Copy Markdown
Member Author

stephentoub commented Apr 28, 2019

In the 3.0 timeframe could we expose the error code value via Exception.Data? Parsing it out of the exception message is an option but one I'd like to avoid.

You said this wasn't blocking. Please avoid doing anything like parsing exception text, which isn't stable and isn't guaranteed from release to release, could be localized and change even in a single release, could change even in a patch, could be stripped out of binaries in tooling for size, etc. Exception.Data is similar.

@JamesNK
Copy link
Copy Markdown
Member

JamesNK commented Apr 28, 2019

Sure. I was thinking of it only as a contingency. The spec says the code is only used to provide more information to the user, but our gRPC interop tests focus on successful scenarios so I'm not completely certain.

- Propagate the GOAWAY and RST_STREAM error codes to the calling code via an exception.
- Propagate to the Http2Stream exceptions incurred in the Http2Connection and that result in an Abort.
- Don't Dispose of the Http2Stream before we try to Cancel it.
- Make Http2ProtocolException serializable, as we generally do that for all of our exception types.
- Add tests that verify sufficient HTTP/2 protocol details are in the exception messages.
- Clean up the error message for the exception.
- Separate the error code and exception into their own files.
- Leave Http2ProtocolException internal for now; we can expose it publicly when we design the all-up public error model for HttpClient.
@stephentoub stephentoub force-pushed the http2protocolexception branch from b5b3308 to 6f0d9d3 Compare April 29, 2019 01:40
@stephentoub stephentoub merged commit 7237da0 into dotnet:master Apr 29, 2019
@stephentoub stephentoub deleted the http2protocolexception branch April 29, 2019 17:51
wfurt added a commit to wfurt/corefx that referenced this pull request Apr 29, 2019
wfurt added a commit that referenced this pull request May 3, 2019
* improve error handling on failed Http/2 handshake

* remove extra space

* add test for HTTP2 client talking to HTTP1 server.

* fix broken tests

* improve exception handling

* update exception handling

* ws update

* fix bad merge

* update test and changes from #37223

* use _abortException only if the stream is not aborted already

* fix IsAborted check

* updates to syncup with recent changes
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Clean up HTTP/2 protocol exception handling

- Propagate the GOAWAY and RST_STREAM error codes to the calling code via an exception.
- Propagate to the Http2Stream exceptions incurred in the Http2Connection and that result in an Abort.
- Don't Dispose of the Http2Stream before we try to Cancel it.
- Make Http2ProtocolException serializable, as we generally do that for all of our exception types.
- Add tests that verify sufficient HTTP/2 protocol details are in the exception messages.
- Clean up the error message for the exception.
- Separate the error code and exception into their own files.
- Leave Http2ProtocolException internal for now; we can expose it publicly when we design the all-up public error model for HttpClient.

* Address PR feedback


Commit migrated from dotnet/corefx@7237da0
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* improve error handling on failed Http/2 handshake

* remove extra space

* add test for HTTP2 client talking to HTTP1 server.

* fix broken tests

* improve exception handling

* update exception handling

* ws update

* fix bad merge

* update test and changes from dotnet/corefx#37223

* use _abortException only if the stream is not aborted already

* fix IsAborted check

* updates to syncup with recent changes


Commit migrated from dotnet/corefx@c412fa7
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP2: Determine how to expose HTTP2 protocol error codes

4 participants