-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Websocket handshake refactoring. #31506
Websocket handshake refactoring. #31506
Conversation
I think the main thing is that the temporary |
Yeah. Instead of allocation you'd do query on request headers directly. public bool IsWebSocketRequest
{
get
{
if (_isWebSocketRequest == null)
{
if (!_upgradeFeature.IsUpgradableRequest)
{
_isWebSocketRequest = false;
}
else
{
_isWebSocketRequest = CheckSupportedWebSocketRequest(_context.Request.Method, _context.Request.Headers);
}
}
return _isWebSocketRequest.Value;
}
}
public static bool CheckSupportedWebSocketRequest(string method, IHeaderDictionary requestHeaders)
{
bool validUpgrade = false, validConnection = false, validKey = false, validVersion = false;
if (!string.Equals("GET", method, StringComparison.OrdinalIgnoreCase))
{
return false;
}
foreach (var pair in requestHeaders)
{
if (string.Equals(HeaderNames.Connection, pair.Key, StringComparison.OrdinalIgnoreCase))
{
check requestHeaders.GetCommaSeparatedValues(HeaderNames.Connection) instead below and other ifs
// if (string.Equals(HeaderNames.Upgrade, pair.Value, StringComparison.OrdinalIgnoreCase))
{
validConnection = true;
}
}
....... |
Assigned to @Tratcher since he suggested the change 😄 |
Hi @BrennanConroy, I have removed an extra parameter to that method, and moved Sorry, if I am missing any important point! |
Hi @umitkavala , Thanks for the reply. But |
Oh good, tests failed, means we have good coverage 😃 |
Addresses #31373
2. Moved intrestingheaders directly to other method instead of paramter (WIP)
1. And refactored a little bit.
Updated |
@@ -146,29 +146,22 @@ public async Task SendLongData_Success() | |||
|
|||
var serverBuffer = new byte[orriginalData.Length]; | |||
var result = await webSocket.ReceiveAsync(new ArraySegment<byte>(serverBuffer), CancellationToken.None); | |||
int intermediateCount = result.Count; |
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 think this test has been broken for 5 years...
Thanks @MCCshreyas ! Hope your computer issues are resolved soon 😃 |
Not yet @BrennanConroy, I ordered a SSD, not sure when it will get delivered now! 😅😅 But thanks for taking care of this PR. 😊 |
Hi @MCCshreyas. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
Addresses #31373
I have moved
CheckSupportedWebSocketRequest
method fromHandShakeHelpers
toWebSocketMiddleware
.I am not getting what needs to be done for
NeededHeaders
do we want to remove those directly?cc @Tratcher