Skip to content
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

[release/6.0] HTTP/3: Support canceling requests that aren't reading a body #35823

Closed
wants to merge 1 commit into from

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Aug 27, 2021

React to dotnet/runtime#58236.

  • New API isn't available yet. Verified it works locally.
  • HttpClient cancellation on abort response isn't available in main so used 6.0 branch temporarily.

@JamesNK JamesNK requested review from Tratcher, wtgodbe and adityamandaleeka and removed request for Tratcher and wtgodbe August 27, 2021 10:20
@@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Connections.Features
public interface IProtocolErrorCodeFeature
{
/// <summary>
/// Gets or sets the error code.
/// Gets or sets the error code. The property returns -1 if the error code hasn't been set.
Copy link
Member Author

Choose a reason for hiding this comment

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

IMO IProtocolErrorCodeFeature.Error should have been nullable, but the API ship sailed in .NET 5.

QUIC and HTTP/3 errors are variable-length integers that are always positive so -1 can be used to represent unset.

var errorCode = stream._errorCodeFeature.Error;
if (errorCode >= 0)
{
stream.Abort(new ConnectionAbortedException(CoreStrings.Http2StreamResetByClient), (Http3ErrorCode)errorCode);
Copy link
Member Author

Choose a reason for hiding this comment

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

This will be updated to call AbortCore when #35764 is merged.

{
// An error code value other than -1 indicates a value was set and the request didn't gracefully complete.
var errorCode = stream._errorCodeFeature.Error;
if (errorCode >= 0)
Copy link
Member

Choose a reason for hiding this comment

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

What does an error code of 0 indicate?

Copy link
Member Author

Choose a reason for hiding this comment

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

It means the stream was aborted with error code of 0. That doesn't have any meaning in HTTP/3, but it's a valid error code for QUIC.

Comment on lines +134 to +136
// TODO: Consider a better way to provide this notification. For perf we want to
// make the ConnectionClosed CTS pay-for-play, and change this event to use
// something that is more lightweight than a CTS.
Copy link
Member

Choose a reason for hiding this comment

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

Can this be created lazily from the RequestAborted property?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we still want to stop and complete the output pipes in this situation. So, we always want this event raised, even if someone hasn't subscribed to RequestAborted.

@JamesNK JamesNK force-pushed the jamesnk/http3-waitwritescomplete branch from c6bf2e7 to 8b32f03 Compare August 30, 2021 04:02
@JamesNK JamesNK force-pushed the jamesnk/http3-waitwritescomplete branch from 8b32f03 to 1e942b2 Compare August 30, 2021 04:48
@JamesNK
Copy link
Member Author

JamesNK commented Sep 2, 2021

Replaced with #36109

@JamesNK JamesNK closed this Sep 2, 2021
@JamesNK JamesNK deleted the jamesnk/http3-waitwritescomplete branch September 4, 2021 05:19
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants