/// <summary> /// Returns the index value for the given header field in the static table. Returns -1 if the /// header field is not in the static table. /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <returns></returns> internal static int GetIndexInsensitive(ICharSequence name, ICharSequence value) { int index = GetIndex(name); if ((uint)index > SharedConstants.TooBigOrNegative /* == -1*/) { return(-1); } uint uLength = (uint)Length; // Note this assumes all entries for a given header field are sequential. while ((uint)index <= uLength) { HpackHeaderField entry = GetEntry(index); if (HpackUtil.EqualsVariableTime(name, entry._name) && HpackUtil.EqualsVariableTime(value, entry._value)) { return(index); } index++; } return(-1); }
/// <summary> /// Returns the lowest index value for the header field name in the dynamic table. Returns -1 if /// the header field name is not in the dynamic table. /// </summary> /// <param name="name"></param> /// <returns></returns> int GetIndex(ICharSequence name) { if (0u >= (uint)Length() || name is null) { return(-1); } int h = AsciiString.GetHashCode(name); int i = Index(h); for (HeaderEntry e = _headerFields[i]; e is object; e = e.Next) { if (e.Hash == h && HpackUtil.EqualsConstantTime(name, e._name) != 0) { return(GetIndex(e.Index)); } } return(-1); }
/// <summary> /// Returns the header entry with the lowest index value for the header field. Returns null if /// header field is not in the dynamic table. /// </summary> /// <param name="name"></param> /// <param name="value"></param> HeaderEntry GetEntryInsensitive(ICharSequence name, ICharSequence value) { if (0u >= (uint)Length() || name is null || value is null) { return(null); } int h = AsciiString.GetHashCode(name); int i = Index(h); for (HeaderEntry e = _headerFields[i]; e is object; e = e.Next) { // Check the value before then name, as it is more likely the value will be different incase there is no // match. if (e.Hash == h && HpackUtil.EqualsVariableTime(value, e._value) && HpackUtil.EqualsVariableTime(name, e._name)) { return(e); } } return(null); }
public bool EqualsForTest(HpackHeaderField other) { return(HpackUtil.EqualsVariableTime(_name, other._name) && HpackUtil.EqualsVariableTime(_value, other._value)); }