Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WebSocketValidate.cs
Go to the documentation of this file.
2
3internal static class WebSocketValidate
4{
5 internal static void ValidateSubprotocol(string subProtocol)
6 {
7 if (string.IsNullOrWhiteSpace(subProtocol))
8 {
10 }
11 string text = null;
12 for (int i = 0; i < subProtocol.Length; i++)
13 {
14 char c = subProtocol[i];
15 if (c < '!' || c > '~')
16 {
17 text = $"[{c}]";
18 break;
19 }
20 if (!char.IsLetterOrDigit(c) && "()<>@,;:\\\"/[]?={} ".IndexOf(c) >= 0)
21 {
22 text = c.ToString();
23 break;
24 }
25 }
26 if (text != null)
27 {
29 }
30 }
31
32 internal static void ValidateArraySegment(ArraySegment<byte> arraySegment, string parameterName)
33 {
34 if (arraySegment.Array == null)
35 {
36 throw new ArgumentNullException(parameterName + ".Array");
37 }
38 if (arraySegment.Offset < 0 || arraySegment.Offset > arraySegment.Array.Length)
39 {
40 throw new ArgumentOutOfRangeException(parameterName + ".Offset");
41 }
42 if (arraySegment.Count < 0 || arraySegment.Count > arraySegment.Array.Length - arraySegment.Offset)
43 {
44 throw new ArgumentOutOfRangeException(parameterName + ".Count");
45 }
46 }
47}
static void ValidateSubprotocol(string subProtocol)
static void ValidateArraySegment(ArraySegment< byte > arraySegment, string parameterName)
static string net_WebSockets_InvalidCharInProtocolString
Definition SR.cs:138
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_WebSockets_InvalidEmptySubProtocol
Definition SR.cs:136
Definition SR.cs:7