sta / websocket-sharp

A C# implementation of the WebSocket protocol client and server

Home Page:http://sta.github.io/websocket-sharp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when proxy server offers multiple authentication methods

georgoswonkos opened this issue · comments

Hi,
I am behind a corporate proxy server with password authentication. Our proxy server offers multiple authentication methods. It's message is:
Proxy-Authenticate: NEGOTIATE,NTLM,BASIC realm="abcde"
In this case websocket-sharp fails to connect because the method Parse expects exactly one authentication method offered by the proxy server.
I made a workaround by using a string search. Can you include it in the master version?

internal static AuthenticationChallenge Parse (string value)
{
      var chal = value.Split (new[] { ' ' }, 2);
      if (chal.Length != 2)
        return null;
      var schm = chal[0].ToLower();
        return schm.Contains("basic")
                ? new AuthenticationChallenge(
                    AuthenticationSchemes.Basic, ParseParameters(chal[1]))
                : schm.Contains("digest")
                    ? new AuthenticationChallenge(
                        AuthenticationSchemes.Digest, ParseParameters(chal[1]))
                    : null;
}