Skip to content

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented Aug 9, 2020

Fixes #24701

Before:

image

After:

image

There are also small performance improvements. gRPC headers are get and set in header collections using fast checks. They don't fallback to using the unknown dictionary collection.

{
"ETag",
"Grpc-Message",
"Grpc-Status"
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about splitting HttpRequestHeaders into Http1RequestHeaders and Http2RequestHeaders? If we include the pseudo-header fields, there are now 9 request header fields in HttpRequestHeaders that I wouldn't expect to be used with HTTP/1.x (though maybe grpc-web means the gRPC headers are also common over HTTP/1.x now).

I'm concerned that using the same HttpRequestHeaders class for HTTP/1.x and HTTP/2 and adding too many HTTP/2-specific headers will slow down HTTP/1.x unnecessarily. We already have 4 HTTP/2 pseudo-header fields in requestPrimaryHeaders. TryGetValueFast will check if the requested header name matches these primary headers before other header names of the same length. Any extra header fields waste memory and slow down methods like Clear, TryGetValueFast, Append, etc...

Copy link
Member Author

@JamesNK JamesNK Aug 11, 2020

Choose a reason for hiding this comment

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

I think that would be a good improvement. I don't know if there will be time for .NET 5.

On primary headers: the HTTP/2 pseudo-headers can probably be removed from primary headers. Pseudo-headers are sent in HEADERS frame as static table indexes. They'll use the upcoming optimizations here: #24730

Copy link
Member

Choose a reason for hiding this comment

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

Are these exact header names used for both HTTP/2 gRPC and gRPC-Web? If so, I guess these warrant being in a possible Http1RequestHeaders dictionary anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

gRPC-Web headers are the same, and gRPC-Web is usable in HTTP/1.1 and 2. So yes it is useful for them to be in a potential Http1RequestHeaders.

The only HTTP/2 specific headers are the pseudo ones.

@JamesNK JamesNK added the api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews label Aug 11, 2020
@ghost
Copy link

ghost commented Aug 11, 2020

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:

  • The PR contains changes to the reference-assembly that describe the API change. Or, you have included a snippet of reference-assembly-style code that illustrates the API change.
  • The PR describes the impact to users, both positive (useful new APIs) and negative (breaking changes).
  • Someone is assigned to "champion" this change in the meeting, and they understand the impact and design of the change.

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

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

LGTM

@JamesNK JamesNK added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels Aug 12, 2020
@JamesNK JamesNK merged commit ffeeb03 into master Aug 12, 2020
@JamesNK JamesNK deleted the jamesnk/knownheaders-grpc branch August 12, 2020 20:59
@JamesNK JamesNK added this to the 5.0.0-rc1 milestone Aug 14, 2020
@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

api-approved API was approved in API review, it can be implemented 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.

Add common gRPC headers to known headers

5 participants