public override bool Equals(object obj)
{
NameValueHeaderValue other = obj as NameValueHeaderValue;
if (other == null)
{
return false;
}
if (!string.Equals(_name, other._name, StringComparison.OrdinalIgnoreCase))
{
return false;
}
// RFC2616: 14.20: unquoted tokens should use case-INsensitive comparison; quoted-strings should use
// case-sensitive comparison. The RFC doesn't mention how to compare quoted-strings outside the "Expect"
// header. We treat all quoted-strings the same: case-sensitive comparison.
if (string.IsNullOrEmpty(_value))
{
return string.IsNullOrEmpty(other._value);
}
if (_value[0] == '"')
{
// We have a quoted string, so we need to do case-sensitive comparison.
return string.Equals(_value, other._value, StringComparison.Ordinal);
}
else
{
return string.Equals(_value, other._value, StringComparison.OrdinalIgnoreCase);
}
}