Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -481,23 +481,28 @@ namespace System.Net.Http.Headers
headers.Add (name, value);
}
var col = (HttpHeaderValueCollection<T>) value.Parsed;
if (value.HasStringValues) {
var hinfo = known_headers[name];
if (value.Parsed == null)
value.Parsed = hinfo.CreateCollection (this);
if (col == null) {
value.Parsed = col = new HttpHeaderValueCollection<T> (this, hinfo);
}
object pvalue;
for (int i = 0; i < value.Values.Count; ++i) {
if (!hinfo.TryParse (value.Values[i], out pvalue))
continue;
hinfo.AddToCollection (value.Parsed, pvalue);
value.Values.RemoveAt (i);
--i;
var svalue = value.Values[i];
if (!hinfo.TryParse (svalue, out pvalue)) {
col.AddInvalidValue (svalue);
} else {
hinfo.AddToCollection (col, pvalue);
}
}
value.Values.Clear ();
}
return (HttpHeaderValueCollection<T>) value.Parsed;
return col;
}
internal void SetValue<T> (string name, T value, Func<object, string> toStringConverter = null)