private List<KeyValuePair> ParseQuotedHeader(string str)
        {
            List<KeyValuePair> result = new List<KeyValuePair>();

            if (str != null)
            {

                int idx = 0;

                // Read Type (Basic|Digest)
                string type = str.Read(ref idx, (ch) => !char.IsWhiteSpace(ch) && !char.IsControl(ch)).TrimAndLower();
                result.Add(new KeyValuePair(type));

                // process the rest of the text
                while (idx < str.Length)
                {
                    // Read key
                    string key = str.Read(ref idx, '=').TrimAndLower();
                    KeyValuePair qp = new KeyValuePair(key);

                    // Skip any white space
                    str.SkipWhiteSpace(ref idx);

                    qp.Value = str.ReadQuotedText(ref idx);

                    result.Add(qp);
                }
            }
            return result;
        }
 public bool TryGet(string value, out KeyValuePair @param)
 {
     @param = null;
     for (int i = 0; i < Values.Count; ++i)
         if (string.CompareOrdinal(Values[i].Key, value) == 0)
         {
             @param = Values[i];
             return true;
         }
     return false;
 }
예제 #3
0
        //deflate, gzip, x-gzip, identity, *;q=0
        internal static List<KeyValuePair> ParseQualityParams(this string str)
        {
            List<KeyValuePair> result = new List<KeyValuePair>();

            if (str == null)
                return result;

            int idx = 0;
            while (idx < str.Length)
            {
                string key = str.Read(ref idx, (ch) => ch != ',' && ch != ';').TrimAndLower();

                KeyValuePair qp = new KeyValuePair(key);

                if (str[idx - 1] == ';')
                {
                    str.Read(ref idx, '=', false);
                    qp.Value = str.Read(ref idx, ',');
                }

                result.Add(qp);
            }

            return result;
        }
예제 #4
0
        //public, max-age=2592000
        internal static List<KeyValuePair> ParseOptionalHeader(this string str)
        {
            List<KeyValuePair> result = new List<KeyValuePair>();

            if (str == null)
                return result;

            int idx = 0;

            // process the rest of the text
            while (idx < str.Length)
            {
                // Read key
                string key = str.Read(ref idx, (ch) => ch != '=' && ch != ',').TrimAndLower();
                KeyValuePair qp = new KeyValuePair(key);

                if (str[idx - 1] == '=')
                    qp.Value = str.ReadQuotedText(ref idx);

                result.Add(qp);
            }

            return result;
        }