fix Ext.cs, WebSocket.cs
This commit is contained in:
parent
5a3545e911
commit
0a07fe449c
@ -1,8 +1,8 @@
|
||||
<Properties>
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release_Ubuntu" ctype="Workspace" />
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug_Ubuntu" ctype="Workspace" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="websocket-sharp/WebSocket.cs" ctype="Workbench">
|
||||
<Files>
|
||||
<File FileName="websocket-sharp/WebSocket.cs" Line="263" Column="2" />
|
||||
<File FileName="websocket-sharp/WebSocket.cs" Line="262" Column="15" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
|
@ -83,27 +83,6 @@ namespace WebSocketSharp
|
||||
return new String(secKey.ToArray());
|
||||
}
|
||||
|
||||
public static IEnumerable<int> IndexOf<T>(this T[] array, T val)
|
||||
{
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (array[i].Equals(val))
|
||||
{
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static T[] InitializeWith<T>(this T[] array, T val)
|
||||
{
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i] = val;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static Byte[] InitializeWithPrintableASCII(this Byte[] bytes, Random rand)
|
||||
{
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
@ -114,11 +93,11 @@ namespace WebSocketSharp
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static void NotEqualsDo(this string a, string b, Action<string, string> action)
|
||||
public static void NotEqualsDo(this string expected, string actual, Action<string, string> action)
|
||||
{
|
||||
if (a != b)
|
||||
if (expected != actual)
|
||||
{
|
||||
action(a, b);
|
||||
action(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +259,11 @@ namespace WebSocketSharp
|
||||
}
|
||||
|
||||
string subProtocol = protocol != String.Empty
|
||||
#if !CHALLENGE
|
||||
? String.Format("WebSocket-Protocol: {0}\r\n", protocol)
|
||||
#else
|
||||
? String.Format("Sec-WebSocket-Protocol: {0}\r\n", protocol)
|
||||
#endif
|
||||
: protocol;
|
||||
#if !CHALLENGE
|
||||
string secKeys = String.Empty;
|
||||
@ -325,17 +329,17 @@ namespace WebSocketSharp
|
||||
Console.WriteLine("{0}", s);
|
||||
}
|
||||
#endif
|
||||
Action<string, string> action = (a, b) =>
|
||||
Action<string, string> action = (e, a) =>
|
||||
{
|
||||
throw new IOException("Invalid handshake response: " + a);
|
||||
};
|
||||
#if !CHALLENGE
|
||||
response[0].NotEqualsDo("HTTP/1.1 101 Web Socket Protocol Handshake", action);
|
||||
"HTTP/1.1 101 Web Socket Protocol Handshake".NotEqualsDo(response[0], action);
|
||||
#else
|
||||
response[0].NotEqualsDo("HTTP/1.1 101 WebSocket Protocol Handshake", action);
|
||||
"HTTP/1.1 101 WebSocket Protocol Handshake".NotEqualsDo(response[0], action);
|
||||
#endif
|
||||
response[1].NotEqualsDo("Upgrade: WebSocket", action);
|
||||
response[2].NotEqualsDo("Connection: Upgrade", action);
|
||||
"Upgrade: WebSocket".NotEqualsDo(response[1], action);
|
||||
"Connection: Upgrade".NotEqualsDo(response[2], action);
|
||||
|
||||
for (int i = 3; i < response.Length; i++)
|
||||
{
|
||||
@ -357,17 +361,15 @@ namespace WebSocketSharp
|
||||
string expectedResToHexStr = BitConverter.ToString(expectedRes);
|
||||
string actualResToHexStr = BitConverter.ToString(actualRes);
|
||||
|
||||
actualResToHexStr.NotEqualsDo(expectedResToHexStr, (a, b) =>
|
||||
{
|
||||
Console.WriteLine("WS: Error @doHandshake: Invalid challenge response.");
|
||||
Console.WriteLine("\texpected: {0}", b);
|
||||
Console.WriteLine("\tactual : {0}", a);
|
||||
throw new IOException("Invalid challenge response: " + a);
|
||||
}
|
||||
);
|
||||
expectedResToHexStr.NotEqualsDo(actualResToHexStr, (e, a) =>
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("WS: Info @doHandshake: challenge response: {0}", actualResToHexStr);
|
||||
Console.WriteLine("WS: Error @doHandshake: Invalid challenge response.");
|
||||
Console.WriteLine("\texpected: {0}", e);
|
||||
Console.WriteLine("\tactual : {0}", a);
|
||||
#endif
|
||||
throw new IOException("Invalid challenge response: " + a);
|
||||
});
|
||||
#endif
|
||||
ReadyState = WsState.OPEN;
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user