- Notifications
You must be signed in to change notification settings - Fork5.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Tagging subscribers to this area: @dotnet/ncl |
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/Compression/WebSocketInflater.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
PaulusParssinen commentedMay 8, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 |
CarnaViire commentedMay 9, 2024
@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.
PaulusParssinenMay 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 thingswould 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.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
* 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
PaulusParssinen commentedMay 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I just realized that
edit: Answer is no. (It is used by couple projects. Need to restore the removed method.) |
This reverts commit053f0ac.
src/libraries/Common/src/System/Net/WebSockets/WebSocketValidate.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/Common/src/System/Net/WebSockets/WebSocketValidate.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketReceiveResult.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketException.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/WebSocketCloseStatus.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
This reverts commit820dc04.
zlatanov commentedMay 10, 2024
LGTM. Thanks! |
CarnaViire left a comment
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 caseRFC6455, 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 commit053f0ac.* Oops* Fix ArgumentNullException for ValidateArraySegment* Revert "Consolidate some validation logic to WebSocketValidata.cs"This reverts commitc515ba9.* Revert ValueWebSocketReceiveResult.ThrowMessageTypeOutOfRange* Revert "Remove unused using directives"This reverts commit820dc04.
Use few newer APIs in the managed websocket implementation. Gets rid of little manual endianness bit-twiddling that is common for code before
BinaryPrimitives.