Skip to content

Commit

Permalink
Avoid closure in WebSocketHandle.ConnectAsync (#50502)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored Apr 1, 2021
1 parent 9e9fb06 commit e5efbd8
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,18 @@ public async Task ConnectAsync(Uri uri, CancellationToken cancellationToken, Cli
string[] subprotocolArray = (string[])subprotocolEnumerableValues;
if (subprotocolArray.Length > 0 && !string.IsNullOrEmpty(subprotocolArray[0]))
{
subprotocol = options.RequestedSubProtocols.Find(requested => string.Equals(requested, subprotocolArray[0], StringComparison.OrdinalIgnoreCase));
if (options._requestedSubProtocols is not null)
{
foreach (string requestedProtocol in options._requestedSubProtocols)
{
if (requestedProtocol.Equals(subprotocolArray[0], StringComparison.OrdinalIgnoreCase))
{
subprotocol = requestedProtocol;
break;
}
}
}

if (subprotocol == null)
{
throw new WebSocketException(
Expand Down

0 comments on commit e5efbd8

Please sign in to comment.