Skip to content

Refactor inefficient WebSocket handshake #31373

Closed

Description

@benaadams

This HandshakeHelpers class is a relic of an outdated design. Can you try simplifying this code by merging this method into the UpgradeHandshake class?

You could remove these allocations and query the header collection directly:

var headers = new List<KeyValuePair<string, string>>();
foreach (string headerName in HandshakeHelpers.NeededHeaders)
{
foreach (var value in _context.Request.Headers.GetCommaSeparatedValues(headerName))
{
headers.Add(new KeyValuePair<string, string>(headerName, value));
}
}

NeededHeaders can also be removed.

#31311 (comment)

Activity

  1. BrennanConroy commented on Apr 29, 2021

    @BrennanConroy
    Member

    Fixed via #31506

  2. ghost locked as resolved and limited conversation to collaborators on May 29, 2021
  3. added
    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
    and removed on Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Perfarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsgood first issueGood for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issue

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions