-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fix sending end stream in http2 web socket stream #73222
Fix sending end stream in http2 web socket stream #73222
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsFixes #72301
|
src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.Http2.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs
Outdated
Show resolved
Hide resolved
2fedcf6
to
c88e46b
Compare
src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.Http2.cs
Outdated
Show resolved
Hide resolved
…st.Http2.cs Co-authored-by: Natalia Kondratyeva <[email protected]>
@stephentoub please can you code review? Thanks! |
src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs
Outdated
Show resolved
Hide resolved
…ttp2.cs Co-authored-by: Stephen Toub <[email protected]>
95d9cfd
to
d2d3ff8
Compare
@@ -1599,7 +1599,7 @@ private async ValueTask<Http2Stream> SendHeadersAsync(HttpRequestMessage request | |||
// Start the write. This serializes access to write to the connection, and ensures that HEADERS | |||
// and CONTINUATION frames stay together, as they must do. We use the lock as well to ensure new | |||
// streams are created and started in order. | |||
await PerformWriteAsync(totalSize, (thisRef: this, http2Stream, headerBytes, endStream: (request.Content == null), mustFlush), static (s, writeBuffer) => | |||
await PerformWriteAsync(totalSize, (thisRef: this, http2Stream, headerBytes, endStream: (request.Content == null && !http2Stream.ConnectProtocolEstablished), mustFlush), static (s, writeBuffer) => |
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.
Maybe I'm doing something wrong, or misunderstanding the change, but if I'm reading this correctly and testing the new feature correctly, this check does nothing because ConnectProtocolEstablished
is only set after the request has already been sent and a response with a 200 was received.
runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs
Lines 640 to 643 in 08a11e4
if (statusCode == 200 && _response.RequestMessage!.IsWebSocketH2Request()) | |
{ | |
ConnectProtocolEstablished = true; | |
} |
Which means every time an HTTP2 WebSocket request is made it will still send the END_STREAM flag.
Did you test this change with Kestrel before merging? Am I holding the feature wrong?
cc @karelz
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.
Sorry, I will double check. I tested it with Kestrel but I probably miss to check state on the server side. Using receive before send works so I thought that the end stream flag causes an issue only on established connection. Also connect without end stream is hanging, I should try different approach.
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 see, I have to switch on flush correctly for both connect and send
Fixes #72301