You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
@ -147,7 +147,7 @@ namespace System.Net.Http.Headers
|
||||
if (t != Token.Type.Token)
|
||||
return false;
|
||||
|
||||
int nvalue;
|
||||
long nvalue;
|
||||
if (!lexer.IsStarStringValue (t)) {
|
||||
if (!lexer.TryGetNumericValue (t, out nvalue)) {
|
||||
var s = lexer.GetStringValue (t);
|
||||
@ -158,12 +158,12 @@ namespace System.Net.Http.Headers
|
||||
if (sep.Length != 2)
|
||||
return false;
|
||||
|
||||
if (!int.TryParse (sep[0], NumberStyles.None, CultureInfo.InvariantCulture, out nvalue))
|
||||
if (!long.TryParse (sep[0], NumberStyles.None, CultureInfo.InvariantCulture, out nvalue))
|
||||
return false;
|
||||
|
||||
value.From = nvalue;
|
||||
|
||||
if (!int.TryParse (sep[1], NumberStyles.None, CultureInfo.InvariantCulture, out nvalue))
|
||||
if (!long.TryParse (sep[1], NumberStyles.None, CultureInfo.InvariantCulture, out nvalue))
|
||||
return false;
|
||||
|
||||
value.To = nvalue;
|
||||
|
@ -70,14 +70,21 @@ namespace System.Net.Http.Headers
|
||||
return null;
|
||||
|
||||
var c = (HttpHeaderValueCollection<U>) collection;
|
||||
if (c.Count == 0)
|
||||
return null;
|
||||
if (c.Count == 0) {
|
||||
if (c.InvalidValues == null)
|
||||
return null;
|
||||
|
||||
return new List<string> (c.InvalidValues);
|
||||
}
|
||||
|
||||
var list = new List<string> ();
|
||||
foreach (var item in c) {
|
||||
list.Add (item.ToString ());
|
||||
}
|
||||
|
||||
if (c.InvalidValues != null)
|
||||
list.AddRange (c.InvalidValues);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ namespace System.Net.Http.Headers
|
||||
readonly List<T> list;
|
||||
readonly HttpHeaders headers;
|
||||
readonly HeaderInfo headerInfo;
|
||||
List<string> invalidValues;
|
||||
|
||||
internal HttpHeaderValueCollection (HttpHeaders headers, HeaderInfo headerInfo)
|
||||
{
|
||||
@ -50,6 +51,12 @@ namespace System.Net.Http.Headers
|
||||
}
|
||||
}
|
||||
|
||||
internal List<string> InvalidValues {
|
||||
get {
|
||||
return invalidValues;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
@ -66,9 +73,18 @@ namespace System.Net.Http.Headers
|
||||
list.AddRange (values);
|
||||
}
|
||||
|
||||
internal void AddInvalidValue (string invalidValue)
|
||||
{
|
||||
if (invalidValues == null)
|
||||
invalidValues = new List<string> ();
|
||||
|
||||
invalidValues.Add (invalidValue);
|
||||
}
|
||||
|
||||
public void Clear ()
|
||||
{
|
||||
list.Clear ();
|
||||
invalidValues = null;
|
||||
}
|
||||
|
||||
public bool Contains (T item)
|
||||
@ -93,11 +109,12 @@ namespace System.Net.Http.Headers
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
// This implementation prints different values than
|
||||
// what .NET does when one of the values is invalid
|
||||
// But it better represents what is actually hold by
|
||||
// the collection
|
||||
return string.Join (headerInfo.Separator, list);
|
||||
var res = string.Join (headerInfo.Separator, list);
|
||||
|
||||
if (invalidValues != null)
|
||||
res += string.Join (headerInfo.Separator, invalidValues);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool TryParseAdd (string input)
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user