-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Kestrel response header encoding #33776
Conversation
/AzurePipelines run AspNetCore-benchmarking-pr |
No pipelines are associated with this pull request. |
src/Servers/Kestrel/Core/src/Internal/Http/HttpResponseHeaders.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Internal/Http3/Http3HeadersEnumerator.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpCharacters.cs
Outdated
Show resolved
Hide resolved
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.
First batch
src/Servers/Kestrel/Core/src/Internal/Http/HttpRequestHeaders.cs
Outdated
Show resolved
Hide resolved
|
||
internal static int GetResponseHeaderStaticTableId(KnownHeaderType responseHeaderType) | ||
{ | ||
// Not Implemented |
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.
When will we need to do this? Do we need to file a followup issue?
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.
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.
Will circle back on reviewing tests. But src changes LGTM
src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
Outdated
Show resolved
Hide resolved
|
||
public Func<string, Encoding?> EncodingSelector { get; set; } = KestrelServerOptions.DefaultHeaderEncodingSelector; | ||
|
||
public int QPackStaticTableId => GetResponseHeaderStaticTableId(_knownHeaderType); |
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.
Where/how is this used?
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.
The pattern is copied from Http2HeadersEnumerator and will be used when implementing #33980.
06634ad
to
b518b31
Compare
[InlineData(2, 2)] | ||
[InlineData(3, 2)] |
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.
We're now using GetMaxByteCount(1) to ensure we have enough space to write at least one character into the buffer, but for ASCII this returns 2 for some reason. I don't know how one char could become two ASCII bytes.
Rebased to resolve merge conflicts. I fixed a bug in WriteEncodedMultiWrite uncovered by the new benchmarks where it didn't ensure buffer space the first time through the loop. |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
{ | ||
_log.QPackEncodingError(_connectionId, streamId, ex); | ||
_connectionContext.Abort(new ConnectionAbortedException(ex.Message, ex)); | ||
_http3Stream.Abort(new ConnectionAbortedException(ex.Message, ex), Http3ErrorCode.InternalError); |
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.
Shouldn't aborting the _connectionContext
abort the stream implicitly?
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.
@JamesNK? I wasn't sure about that part, I know state is tracked much differently from HTTP/2.
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:
|
Please watch the benchmarks after this change makes it all the way in. |
Fixes #4727
I have all of the plumbing in place with tests written and passing, but there's plenty of room to clean it up.
TODO:
cc: @benaadams
ResponseHeadersWritingBenchmark (HTTP/1)
Before:
After, default encoder:
After, utf8 encoder:
HPackHeaderWriterBenchmark (Http/2)
Before:
After:
Crank Plaintext default encoding: