-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Utilize new APIs in the WebSocket implementation #101953
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
|
Tagging subscribers to this area: @dotnet/ncl |
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/Compression/WebSocketInflater.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs
Outdated
Show resolved
Hide resolved
|
Assuming the CI failures are unrelated but the fails were about missing log artifact directory, so I'm rolling the CI roulette one more time. edit: hooray, finally green |
|
@zlatanov JFYI |
| sendBuffer[i] = unchecked((byte)length); | ||
| length /= 256; | ||
| } | ||
| BinaryPrimitives.WriteUInt64BigEndian(sendBuffer.AsSpan(2), (ulong)payload.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.
We do already have a test that would verify it, is that correct?
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.
Not explicitly, but the deflate / inflate tests would hit this and verify its correctness.
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 testing coverage is dangerously low but a lot of things would should have broke if these were wrong, for example the compression tests as said above😅
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs
Outdated
Show resolved
Hide resolved
* Implementation detail, both would work
RFC6455, Section 5.2. quote: "If 126, the following 2 bytes interpreted as a 16-bit unsigned integer are the payload length."
* Use CallerArgumentExpression to flow the parameterName in ValidateArraySegment
|
I just realized that
edit: Answer is no. (It is used by couple projects. Need to restore the removed method.) |
This reverts commit 053f0ac.
src/libraries/Common/src/System/Net/WebSockets/WebSocketValidate.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Net/WebSockets/WebSocketValidate.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketReceiveResult.cs
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.cs
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketCloseStatus.cs
Show resolved
Hide resolved
This reverts commit 820dc04.
|
LGTM. Thanks! |
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.
LGTM, thanks! (and sorry for the delay)
* Use BinaryPrimitives in ManagedWebSocket * Use MemoryMarshal.CreateSpan instead of .ctor in WebSocketInflater * Apply PR suggestion * Use BinaryPrimitives in more places * Restore the behavior where mask is stored in machine-endianness * Implementation detail, both would work * Remove unused using directives * Read the payload length as unsigned for 16-bit case RFC6455, Section 5.2. quote: "If 126, the following 2 bytes interpreted as a 16-bit unsigned integer are the payload length." * Consolidate some validation logic to WebSocketValidata.cs * Use CallerArgumentExpression to flow the parameterName in ValidateArraySegment * Remove unused ValidateBuffer * Use new throw helpers in ValueWebSocketReceiveResult * Use ValueTask.FromException * Revert "Remove unused ValidateBuffer" This reverts commit 053f0ac. * Oops * Fix ArgumentNullException for ValidateArraySegment * Revert "Consolidate some validation logic to WebSocketValidata.cs" This reverts commit c515ba9. * Revert ValueWebSocketReceiveResult.ThrowMessageTypeOutOfRange * Revert "Remove unused using directives" This reverts commit 820dc04.
Use few newer APIs in the managed websocket implementation. Gets rid of little manual endianness bit-twiddling that is common for code before
BinaryPrimitives.