Refactored AuthenticationChallenge.cs
This commit is contained in:
parent
b2559a3276
commit
7ed991d72e
@ -117,8 +117,9 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
public static AuthenticationChallenge Parse (string value)
|
public static AuthenticationChallenge Parse (string value)
|
||||||
{
|
{
|
||||||
var challenge = value.Split (new char [] {' '}, 2);
|
var challenge = value.Split (new [] { ' ' }, 2);
|
||||||
var scheme = challenge [0].ToLower ();
|
var scheme = challenge [0].ToLower ();
|
||||||
|
|
||||||
return scheme == "basic" || scheme == "digest"
|
return scheme == "basic" || scheme == "digest"
|
||||||
? new AuthenticationChallenge (scheme, challenge [1])
|
? new AuthenticationChallenge (scheme, challenge [1])
|
||||||
: null;
|
: null;
|
||||||
|
@ -606,26 +606,20 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
internal static NameValueCollection ParseAuthParams (this string value)
|
internal static NameValueCollection ParseAuthParams (this string value)
|
||||||
{
|
{
|
||||||
var result = new NameValueCollection ();
|
var res = new NameValueCollection ();
|
||||||
var i = 0;
|
|
||||||
string name, val;
|
|
||||||
foreach (var param in value.SplitHeaderValue (',')) {
|
foreach (var param in value.SplitHeaderValue (',')) {
|
||||||
i = param.IndexOf ('=');
|
var i = param.IndexOf ('=');
|
||||||
if (i > 0) {
|
var name = i > 0 ? param.Substring (0, i).Trim () : null;
|
||||||
name = param.Substring (0, i).Trim ();
|
var val = i < 0
|
||||||
val = i < param.Length - 1
|
? param.Trim ().Trim ('"')
|
||||||
? param.Substring (i + 1).Trim ().Trim ('"')
|
: param.Length > i + 1
|
||||||
: String.Empty;
|
? param.Substring (i + 1).Trim ().Trim ('"')
|
||||||
}
|
: String.Empty;
|
||||||
else {
|
|
||||||
name = param;
|
|
||||||
val = String.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Add (name, val);
|
res.Add (name, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static byte [] ReadBytes (this Stream stream, int length)
|
internal static byte [] ReadBytes (this Stream stream, int length)
|
||||||
|
Loading…
Reference in New Issue
Block a user