예제 #1
0
        internal HttpHeaderValueCollection <T> GetValues <T> (string name) where T : class
        {
            HeaderBucket value;

            if (!headers.TryGetValue(name, out value))
            {
                var hinfo = known_headers[name];
                value = new HeaderBucket(new HttpHeaderValueCollection <T> (this, hinfo), hinfo.CustomToString);
                headers.Add(name, value);
            }

            var col = (HttpHeaderValueCollection <T>)value.Parsed;

            if (value.HasStringValues)
            {
                var hinfo = known_headers[name];
                if (col == null)
                {
                    value.Parsed = col = new HttpHeaderValueCollection <T> (this, hinfo);
                }

                object pvalue;
                for (int i = 0; i < value.Values.Count; ++i)
                {
                    var svalue = value.Values[i];
                    if (!hinfo.TryParse(svalue, out pvalue))
                    {
                        col.AddInvalidValue(svalue);
                    }
                    else
                    {
                        hinfo.AddToCollection(col, pvalue);
                    }
                }

                value.Values.Clear();
            }

            return(col);
        }
예제 #2
0
 private static void ValidateToken(HttpHeaderValueCollection <string> collection, string value)
 {
     CheckValidToken(value, "item");
 }