sta / sta/websocket-sharp

Digest authentication exception

Open
#29 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

The body in the 401 response is not read which makes the authentication to fail, I get the exception ("No colon found.", "header").

If I read the body after the header in the method WsStream::ReadHandshake then it works fine.

if (_innerStream.ReadByte().EqualsWith('\r', add) &&
_innerStream.ReadByte().EqualsWith('\n', add) &&
_innerStream.ReadByte().EqualsWith('\r', add) &&
_innerStream.ReadByte().EqualsWith('\n', add))
{
string tempRes = Encoding.UTF8.GetString(buffer.ToArray());
var clStartIndex = tempRes.IndexOf("Content-Length:");
if (-1 != clStartIndex)
{
clStartIndex += ("Content-Length:".Length + 1);
int crIndex = tempRes.IndexOf('\r', clStartIndex);
string contentLenStr = tempRes.Substring(clStartIndex, crIndex - clStartIndex);
int contentLen = Convert.ToInt32(contentLenStr);
for (int i = 0; i < contentLen; ++i)
{
_innerStream.ReadByte();
}
}

    read = true;
    break;

}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in WsStream::ReadHandshake and reproduce the digest-authentication failure for a 401 response. Trace how the response header and Content-Length are handled, then verify that the response body is consumed before authentication parsing and that the "No colon found." exception no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.