-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add HTTP/2 HPack static compression #19521
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
If you are adding an - if ((_bits & 0x1L) != 0)
+ if ((_bits & KnownHeaderType.CacheControl) != 0)
{
_current = new KeyValuePair<string, StringValues>(HeaderNames.CacheControl, _collection._headers._CacheControl);
_currentKnownType = KnownHeaderType.CacheControl;
_next = 1;
return true;
} |
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.
Any luck cleaning up HPackEncoder.BeginEncode?
Any influence on benchmarks?
I was going to ask about static value encoding, but status is the only response header with values in the static table isn't it?
Not your problem, but still not pleased about the duplication here between the client and the server.
src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
Outdated
Show resolved
Hide resolved
return true; | ||
} | ||
|
||
private static bool EncodeHeader(KnownHeaderType knownHeaderType, string name, string value, Span<byte> buffer, out int length) |
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 had envisioned this method and the enum being in the shared code, but I can understand why you would want to stop here. The client has almost this exact code for request headers but it will take some more work to deduplicate.
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 at least now using the same static helper methods.
I'm not sure where the client would use a method like EncodeHeader. Many of their headers are written explicitly, and their unknown headers are written here - https://github.com/dotnet/runtime/blob/master/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs#L1021
I'm not sure how their header buffer handles splitting content across multiple HEADER frames.
Is there somewhere else in the client that I'm missing?
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 meant that translations like HPackHeaderMapping.GetResponseHeaderStaticTableId would be done inside the HPack implementation.
Maybe. We might end up using KnownHeaderType as an index in an array of header metadata. That metadata would include the static compression ID, pre-encoded header names, etc. A flag enum wouldn't work in that situation. |
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.
Mainly waiting on HPackEncoder.BeginEncode cleanup and benchmarks.
src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs
Outdated
Show resolved
Hide resolved
8fd9655
to
c704590
Compare
|
||
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2 | ||
{ | ||
internal static class HPackHeaderWriter |
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.
This is copy and paste (with some modifications to remove some internal type dependencies) but that appears to match the other code in http2cat which is copied from Http2TestBase
|
||
namespace System.Net.Http.HPack | ||
{ | ||
internal class HPackEncoder | ||
internal static class HPackEncoder |
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.
State gone! @scalablecory @Tratcher
src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2TestBase.cs
Outdated
Show resolved
Hide resolved
294b411
to
b1d9b53
Compare
Fixes #4716
I haven't benchmarked anything yet but response HEADERS frames in unit tests are expectedly smaller.
There are a lot of test failures, but that is because I haven't updated the expected length for HEADERS. Will deal with those once we're happy with the approach.