Skip to content

Commit

Permalink
Fix Bug: .NetFramework 4.8 ClientWebSocket Cann't Connect To .Net8 Ws…
Browse files Browse the repository at this point in the history
…Session #278
  • Loading branch information
chronoxor committed Dec 23, 2023
1 parent 03a81a2 commit fcbbcb7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion source/NetCoreServer/NetCoreServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>8.0.5.0</Version>
<Version>8.0.6.0</Version>
<Authors>Ivan Shynkarenka</Authors>
<Copyright>Copyright (c) 2019-2023 Ivan Shynkarenka</Copyright>
<RepositoryUrl>https://github.com/chronoxor/NetCoreServer</RepositoryUrl>
Expand Down
9 changes: 1 addition & 8 deletions source/NetCoreServer/WebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,7 @@ public bool PerformServerUpgrade(HttpRequest request, HttpResponse response)

if (string.Compare(key, "Connection", StringComparison.OrdinalIgnoreCase) == 0)
{
var values = value.Split(',').Select(str => str.Trim()).ToArray();
if ((values.Length == 0) ||
((values.Length == 1) && (string.Compare(values[0], "Upgrade", StringComparison.OrdinalIgnoreCase) != 0)) ||
((values.Length == 2) && !(
((string.Compare(values[0], "Upgrade", StringComparison.OrdinalIgnoreCase) == 0) && (string.Compare(values[1], "keep-alive", StringComparison.OrdinalIgnoreCase) == 0)) ||
((string.Compare(values[0], "keep-alive", StringComparison.OrdinalIgnoreCase) == 0) && (string.Compare(values[1], "Upgrade", StringComparison.OrdinalIgnoreCase) == 0))
)) ||
(values.Length > 2))
if ((string.Compare(value, "Upgrade", StringComparison.OrdinalIgnoreCase) != 0) && (string.Compare(value.RemoveWhiteSpace(), "keep-alive,Upgrade", StringComparison.OrdinalIgnoreCase) != 0))
{
error = true;
response.MakeErrorResponse(400, "Invalid WebSocket handshaked request: 'Connection' header value must be 'Upgrade' or 'Upgrade, keep-alive'");
Expand Down

0 comments on commit fcbbcb7

Please sign in to comment.