-
Notifications
You must be signed in to change notification settings - Fork 10.4k
HTTP/3: Add IStreamAbortFeature #34409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bcfc1b4
to
6c837c9
Compare
/// <summary> | ||
/// Abort the read side of the connection stream. | ||
/// </summary> | ||
/// <param name="errorCode">The error code to send with the abort.</param> | ||
/// <param name="abortReason">An optional <see cref="ConnectionAbortedException"/> describing the reason to abort the read side of the connection stream.</param> | ||
void AbortRead(long errorCode, ConnectionAbortedException abortReason); | ||
|
||
/// <summary> | ||
/// Abort the write side of the connection stream. | ||
/// </summary> | ||
/// <param name="errorCode">The error code to send with the abort.</param> | ||
/// <param name="abortReason">An optional <see cref="ConnectionAbortedException"/> describing the reason to abort the write side of the connection stream.</param> | ||
void AbortWrite(long errorCode, ConnectionAbortedException abortReason); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In HTTP/3 the read and write sides of the stream can be aborted independently. An error code is sent with these aborts.
I followed the pattern of ConnectionContext.Abort(ConnectionAbortedException abortReason)
which uses the exception to pass in a reason. The reason isn't sent to the peer in HTTP/3 and is only used by logging. It can be removed if we don't think logging a reason in the transport adds value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do thumbs up mean keep the exception? 😄
Update: Ok, I see the point of passing exception in now. It is used with Input.Complete and Output.Complete.
{ | ||
if (_stream.CanRead) | ||
{ | ||
_log.StreamAbortRead(this, abortReason.Message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's an active reader, can we throw this ConnectionAbortedException from the current read similar to what we do with SocketConnection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a test and see what happens.
Assert.Contains(LogMessages, m => m.Message.Contains("the application completed without reading the entire request body.")); | ||
Assert.Equal("The application completed without reading the entire request body.", requestStream.AbortReadException.Message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this effectively get logged twice now? I'm okay with it if it's different categories and they're both debug level. Just checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's logged once at the HTTP layer and once and the transport layer.
62bbcbb
to
c115fc8
Compare
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
src/Servers/Connections.Abstractions/src/Features/IStreamAbortFeature.cs
Outdated
Show resolved
Hide resolved
src/Servers/Connections.Abstractions/src/Features/IStreamAbortFeature.cs
Outdated
Show resolved
Hide resolved
c115fc8
to
d348453
Compare
d348453
to
ed7e709
Compare
Fixes #31970
Fixes #33575
HTTP/3 streams support aborting individual sides of a connection stream. Feature is so HTTP layer can abort reading/writing in transport layer.
Args:
errorCode
is sent to the peer. long is used because it is variable length.Example usage:
The client is uploading data to the server in an HTTP/3 request. The server completes
RequestDelegate
(i.e. user app code) without reading all of the data. HTTP/3 layer in the server will gracefully finish writing the response and abort reading the request. The abort tells the client it can stop uploading.