Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -94,7 +94,7 @@ namespace System.Net.Http.Headers
/*90*/ true, false, false, false, true, true, true, true, true, true,
/*100*/ true, true, true, true, true, true, true, true, true, true,
/*110*/ true, true, true, true, true, true, true, true, true, true,
/*120*/ true, true, true, false, true, false
/*120*/ true, true, true, false, true, false, true
};
static readonly int last_token_char = token_chars.Length;
@@ -153,6 +153,11 @@ namespace System.Net.Http.Headers
return int.TryParse (GetStringValue (token), NumberStyles.None, CultureInfo.InvariantCulture, out value);
}
public bool TryGetNumericValue (Token token, out long value)
{
return long.TryParse (GetStringValue (token), NumberStyles.None, CultureInfo.InvariantCulture, out value);
}
public TimeSpan? TryGetTimeSpanValue (Token token)
{
int seconds;
@@ -202,7 +207,7 @@ namespace System.Net.Http.Headers
public static bool IsValidCharacter (char input)
{
return input <= last_token_char && token_chars[input];
return input < last_token_char && token_chars[input];
}
public void EatChar ()
@@ -232,10 +237,20 @@ namespace System.Net.Http.Headers
return false;
}
int parens = 1;
while (pos < s.Length) {
var ch = s[pos];
if (ch == '(') {
++parens;
++pos;
continue;
}
if (ch == ')') {
++pos;
if (--parens > 0)
continue;
var start = readToken.StartPosition;
value = s.Substring (start, pos - start);
return true;
@@ -297,18 +312,11 @@ namespace System.Net.Http.Headers
// Quoted string
start = pos - 1;
while (pos < s.Length) {
ch = s[pos];
ch = s [pos++];
if (ch == '"') {
++pos;
ttype = Token.Type.QuotedString;
break;
}
// any OCTET except CTLs, but including LWS
if (ch < 32 || ch > 126)
break;
++pos;
}
break;
@@ -317,13 +325,13 @@ namespace System.Net.Http.Headers
ttype = Token.Type.OpenParens;
break;
default:
if (ch <= last_token_char && token_chars[ch]) {
if (ch < last_token_char && token_chars[ch]) {
start = pos - 1;
ttype = Token.Type.Token;
while (pos < s.Length) {
ch = s[pos];
if (ch > last_token_char || !token_chars[ch]) {
if (ch >= last_token_char || !token_chars[ch]) {
break;
}