Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetParsedValueLength()

override int System.Net.Http.Headers.AltSvcHeaderParser.GetParsedValueLength ( string value,
int startIndex,
object storeValue,
out object parsedValue )
inlineprotected

Definition at line 16 of file AltSvcHeaderParser.cs.

17 {
18 if (string.IsNullOrEmpty(value))
19 {
20 parsedValue = null;
21 return 0;
22 }
23 int num = startIndex;
24 if (!TryReadPercentEncodedAlpnProtocolName(value, num, out var result, out var readLength))
25 {
26 parsedValue = null;
27 return 0;
28 }
29 num += readLength;
30 if (result == "clear")
31 {
32 if (num != value.Length)
33 {
34 parsedValue = null;
35 return 0;
36 }
37 parsedValue = AltSvcHeaderValue.Clear;
38 return num - startIndex;
39 }
40 if (num == value.Length || value[num++] != '=')
41 {
42 parsedValue = null;
43 return 0;
44 }
45 if (!TryReadQuotedAltAuthority(value, num, out var host, out var port, out var readLength2))
46 {
47 parsedValue = null;
48 return 0;
49 }
50 num += readLength2;
51 int? num2 = null;
52 bool persist = false;
53 while (num != value.Length)
54 {
55 for (; num != value.Length && IsOptionalWhiteSpace(value[num]); num++)
56 {
57 }
58 if (num == value.Length)
59 {
60 parsedValue = null;
61 return 0;
62 }
63 switch (value[num])
64 {
65 default:
66 parsedValue = null;
67 return 0;
68 case ';':
69 {
70 for (num++; num != value.Length && IsOptionalWhiteSpace(value[num]); num++)
71 {
72 }
73 int tokenLength = HttpRuleParser.GetTokenLength(value, num);
74 if (tokenLength == 0)
75 {
76 parsedValue = null;
77 return 0;
78 }
79 if (num + tokenLength >= value.Length || value[num + tokenLength] != '=')
80 {
81 parsedValue = null;
82 return 0;
83 }
84 if (tokenLength == 2 && value[num] == 'm' && value[num + 1] == 'a')
85 {
86 num += 3;
87 if (!TryReadTokenOrQuotedInt32(value, num, out var result2, out var readLength3))
88 {
89 parsedValue = null;
90 return 0;
91 }
92 num2 = (num2.HasValue ? new int?(Math.Min(num2.GetValueOrDefault(), result2)) : new int?(result2));
93 num += readLength3;
94 }
95 else if (value.AsSpan(num).StartsWith("persist="))
96 {
97 num += 8;
98 if (TryReadTokenOrQuotedInt32(value, num, out var result3, out var readLength4))
99 {
100 persist = result3 == 1;
101 }
102 else if (!TrySkipTokenOrQuoted(value, num, out readLength4))
103 {
104 parsedValue = null;
105 return 0;
106 }
107 num += readLength4;
108 }
109 else
110 {
111 num += tokenLength + 1;
112 if (!TrySkipTokenOrQuoted(value, num, out var readLength5))
113 {
114 parsedValue = null;
115 return 0;
116 }
117 num += readLength5;
118 }
119 continue;
120 }
121 case ',':
122 break;
123 }
124 break;
125 }
126 TimeSpan maxAge = TimeSpan.FromTicks(((long?)num2 * 10000000L) ?? 864000000000L);
127 parsedValue = new AltSvcHeaderValue(result, host, port, maxAge, persist);
128 return num - startIndex;
129 }
static bool TrySkipTokenOrQuoted(string value, int startIndex, out int readLength)
static bool TryReadQuotedAltAuthority(string value, int startIndex, out string host, out int port, out int readLength)
static bool TryReadTokenOrQuotedInt32(string value, int startIndex, out int result, out int readLength)
static bool TryReadPercentEncodedAlpnProtocolName(string value, int startIndex, [NotNullWhen(true)] out string result, out int readLength)

References System.Net.Http.Headers.AltSvcHeaderValue.Clear, System.TimeSpan.FromTicks(), System.Net.Http.HttpRuleParser.GetTokenLength(), System.Net.Http.Headers.AltSvcHeaderParser.IsOptionalWhiteSpace(), System.L, System.Math.Min(), System.startIndex, System.Net.Http.Headers.AltSvcHeaderParser.TryReadPercentEncodedAlpnProtocolName(), System.Net.Http.Headers.AltSvcHeaderParser.TryReadQuotedAltAuthority(), System.Net.Http.Headers.AltSvcHeaderParser.TryReadTokenOrQuotedInt32(), System.Net.Http.Headers.AltSvcHeaderParser.TrySkipTokenOrQuoted(), and System.value.