fix Ext.cs, WebSocket.cs
This commit is contained in:
parent
517fd4d8fd
commit
e72bdb0954
@ -2,7 +2,7 @@
|
|||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug_Ubuntu" ctype="Workspace" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug_Ubuntu" ctype="Workspace" />
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="websocket-sharp/WebSocket.cs" ctype="Workbench">
|
<MonoDevelop.Ide.Workbench ActiveDocument="websocket-sharp/WebSocket.cs" ctype="Workbench">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="websocket-sharp/WebSocket.cs" Line="262" Column="15" />
|
<File FileName="websocket-sharp/WebSocket.cs" Line="249" Column="1" />
|
||||||
</Files>
|
</Files>
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
|
@ -34,9 +34,9 @@ namespace WebSocketSharp
|
|||||||
{
|
{
|
||||||
public static class Ext
|
public static class Ext
|
||||||
{
|
{
|
||||||
public static bool EqualsWithSaveTo(this int asbyte, char c, List<byte> dist)
|
public static bool EqualsWithSaveTo(this int asByte, char c, List<byte> dist)
|
||||||
{
|
{
|
||||||
byte b = (byte)asbyte;
|
byte b = (byte)asByte;
|
||||||
dist.Add(b);
|
dist.Add(b);
|
||||||
return b == Convert.ToByte(c);
|
return b == Convert.ToByte(c);
|
||||||
}
|
}
|
||||||
@ -68,17 +68,17 @@ namespace WebSocketSharp
|
|||||||
List<char> secKey = new List<char>(mKey.ToString().ToCharArray());
|
List<char> secKey = new List<char>(mKey.ToString().ToCharArray());
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (int n = 0; n < ascii; n++)
|
ascii.Times( () =>
|
||||||
{
|
{
|
||||||
i = rand.Next(secKey.Count + 1);
|
i = rand.Next(secKey.Count + 1);
|
||||||
secKey.Insert(i, rand.GeneratePrintableASCIIwithoutSPandNum());
|
secKey.Insert(i, rand.GeneratePrintableASCIIwithoutSPandNum());
|
||||||
}
|
} );
|
||||||
|
|
||||||
for (int n = 0; n < space; n++)
|
space.Times( () =>
|
||||||
{
|
{
|
||||||
i = rand.Next(1, secKey.Count);
|
i = rand.Next(1, secKey.Count);
|
||||||
secKey.Insert(i, ' ');
|
secKey.Insert(i, ' ');
|
||||||
}
|
} );
|
||||||
|
|
||||||
return new String(secKey.ToArray());
|
return new String(secKey.ToArray());
|
||||||
}
|
}
|
||||||
@ -93,11 +93,19 @@ namespace WebSocketSharp
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void NotEqualsDo(this string expected, string actual, Action<string, string> action)
|
public static void NotEqualsDo(this string expected, string actual, Action<string, string> act)
|
||||||
{
|
{
|
||||||
if (expected != actual)
|
if (expected != actual)
|
||||||
{
|
{
|
||||||
action(expected, actual);
|
act(expected, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Times(this int n, Action act)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
act();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,17 +329,17 @@ namespace WebSocketSharp
|
|||||||
Console.WriteLine("{0}", s);
|
Console.WriteLine("{0}", s);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Action<string, string> action = (e, a) =>
|
Action<string, string> act = (e, a) =>
|
||||||
{
|
{
|
||||||
throw new IOException("Invalid handshake response: " + a);
|
throw new IOException("Invalid handshake response: " + a);
|
||||||
};
|
};
|
||||||
#if !CHALLENGE
|
#if !CHALLENGE
|
||||||
"HTTP/1.1 101 Web Socket Protocol Handshake".NotEqualsDo(response[0], action);
|
"HTTP/1.1 101 Web Socket Protocol Handshake".NotEqualsDo(response[0], act);
|
||||||
#else
|
#else
|
||||||
"HTTP/1.1 101 WebSocket Protocol Handshake".NotEqualsDo(response[0], action);
|
"HTTP/1.1 101 WebSocket Protocol Handshake".NotEqualsDo(response[0], act);
|
||||||
#endif
|
#endif
|
||||||
"Upgrade: WebSocket".NotEqualsDo(response[1], action);
|
"Upgrade: WebSocket".NotEqualsDo(response[1], act);
|
||||||
"Connection: Upgrade".NotEqualsDo(response[2], action);
|
"Connection: Upgrade".NotEqualsDo(response[2], act);
|
||||||
|
|
||||||
for (int i = 3; i < response.Length; i++)
|
for (int i = 3; i < response.Length; i++)
|
||||||
{
|
{
|
||||||
|
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